小编2am*_*2am的帖子

如何使带有自制库的 Xcode 项目可移植?

我已经使用 Brew 在我的 mac 上安装了 FreeType。我的 mac 上的代码工作正常,但是当我尝试在其他 mac 上运行该项目时,我收到下面提到的链接错误。

dyld: Library not loaded: /usr/local/opt/freetype/lib/libfreetype.6.dylib
Referenced from: /Users/ashutosh/Library/Developer/Xcode/DerivedData/InstrumentChamp- 
etytleaabhxmokadgrjzbgtmwxfl/Build/Products/Debug/instrumentchamp.app/Contents/MacOS/instrumentchamp
Reason: image not found (lldb) 
Run Code Online (Sandbox Code Playgroud)

当我尝试在其他 Mac 上运行代码时,Freetype 的所有库目录和包含目录都包含在项目的“$SRCROOT/”目录中。

您在库的链接错误中看到的路径是brew 在我创建此项目的mac 中安装freetype 的位置。

/usr/local/opt/freetype/lib/libfreetype.6.dylib
Run Code Online (Sandbox Code Playgroud)

我已将所需的所有 lib/ include/ 目录复制到我的项目的主文件夹中。
我已经在 Xcode 中设置了库并包含路径。

我在这里缺少什么?我还需要做什么才能使我的代码在任何其他 Mac 上可移植。我通过安装 Brew 让项目在其他 Mac 上运行,但我想不需要安装 Brew 即可完成此操作。

PS:我必须使用brew安装freetype,因为我无法为32位处理器的freetype编译.dylib,.dylib的64位副本给我错误,例如“错误的架构!”

opengl macos xcode homebrew freetype

6
推荐指数
1
解决办法
6315
查看次数

在C ++中使用cURL进行JSON请求

我在cURL中有以下命令,在终端中可以正常工作。

curl --insecure -X POST --data "username=testuser&password=12345" https://m360-prototype.herokuapp.com/sessions.json

这个json api发送一些这样的参数- "status":{"code":200,"message":"OK"}

现在我希望我的C ++程序执行它。我已经设置并使用cURL进行ftp上传和从ftp示例下载。但是我没有找到任何这样做的例子。

我想知道如何将用户名和密码参数传递给json api,并从中获取响应。

这是我在网上找到的一些代码中尝试过的方法,它没有起作用。

struct curl_slist *headers=NULL; // init to NULL is important

headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");

curl = curl_easy_init();
if(curl) {
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    curl_easy_setopt(curl, CURLOPT_URL, "https://m360-prototype.herokuapp.com/sessions.json");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "username=testuser&password=12345");

    curl_easy_setopt(curl, CURLOPT_HTTPGET,1);
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    res = curl_easy_perform(curl);

    if(CURLE_OK == res) {
        char *ct;
        /* ask for the content-type */
        res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
        if((CURLE_OK …
Run Code Online (Sandbox Code Playgroud)

c++ json curl

5
推荐指数
2
解决办法
1万
查看次数

为什么 [ fopen() / open() / fstream file ] 在 Mac OS X 上打开文件失败?

我正在尝试在 Mac OS X 上打开 tga 文件,过去一个小时我一直在摆弄这个问题,但没有成功。我只想打开 .tga 文件。这是我到目前为止所尝试过的,

    int filedesc = open("/Users/x2am/Desktop/1177.tga", O_RDONLY);
    if(filedesc < 0)
            printf("%s ",strerror(errno));
Run Code Online (Sandbox Code Playgroud)

输出> 不允许操作

    FILE* fp = fopen("/Users/x2am/Desktop/1177.tga", "rb");
    if(fp == NULL) printf("file not loaded");
Run Code Online (Sandbox Code Playgroud)

输出> 文件未加载

   filename = L"/Users/x2am/Desktop/1177.tga";
   std::string narrow(filename.begin(), filename.end());
   fstream file(narrow.c_str(), ios::in | ios::binary);
   if (!file.good()) printf("file not loaded");
Run Code Online (Sandbox Code Playgroud)

输出> 文件未加载

考虑到 open() 的输出,不知何故该操作是不允许的。

这是我在图像上执行的获取信息。

在此输入图像描述

该应用程序是沙盒的, 在此输入图像描述

现在我想我已经尽力了。是不是有什么看不见的东西就在我的面前,而我却错过了?非常感谢任何帮助:)

c c++ macos file

2
推荐指数
1
解决办法
3855
查看次数

标签 统计

c++ ×2

macos ×2

c ×1

curl ×1

file ×1

freetype ×1

homebrew ×1

json ×1

opengl ×1

xcode ×1