【问题标题】:Objective-C and CObjective-C 和 C
【发布时间】:2010-08-24 08:10:56
【问题描述】:

我尝试使用“libmsrp”,但是当我尝试编译库时,出现以下错误:

$ make so
gcc -ggdb -shared -Wl,-soname,libmsrp.so.0 -o libmsrp.so.0.0.2 msrp.o msrp_session.o msrp_message.o msrp_relay.o msrp_switch.o msrp_callback.o msrp_network.o msrp_utils.o -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -lpthread
ld: unknown option: -soname
collect2: ld returned 1 exit status
make: *** [so] Error 1

所以我将 -soname 选项更改为 -dylib_install_name -Wl。编译后出现以下错误:

$ make so
gcc -ggdb -shared -Wl,-dylib_install_name -Wl,libmsrp.dylib.0.0.2 -o libmsrp.dylib.0.0.2 msrp.o msrp_session.o msrp_message.o msrp_relay.o msrp_switch.o msrp_callback.o msrp_network.o msrp_utils.o -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -lpthread <p>
Undefined symbols:<p>
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [so] Error 1

所以,我尝试在 Objective-C 项目中进行编译。我添加源文件和头文件并编译项目。

我收到以下错误:

command: MSRP_LIST_FREE(sessions, sessions_lock);

msrp.c:75: error: expected ';' before 'temp'
msrp.c:75: error: 'temp' undeclared (first use in this function)
msrp.c:75: error: 'next' undeclared (first use in this function)
msrp.c:75: error: expected ';' before 'temp'
msrp.c:75: error: 'previous' undeclared (first use in this function)

声明:

#define MSRP_LIST_FREE(list, lock
if(!(list))
    return 0;
else {
    typeof((list)) temp = list, next = NULL;
    while(temp) {
        next = temp->next;
        MSRP_LIST_REMOVE((list), (lock), temp);
        temp = next
    }
}

有什么想法吗?

【问题讨论】:

    标签: objective-c c compiler-errors


    【解决方案1】:

    可能,makefile 会处理一些在您从源代码编译时未设置的定义。 您应该继续与 make 斗争以使其编译;) 或许,您应该尝试使用 gmake 而不是 make。

    【讨论】:

      【解决方案2】:

      -soname 应该是-install_name 我认为(不是-dylib_install_name)。无论如何,当我进行更改时,它会干净地编译。

      这是我的 make 文件中的内容:

      gcc -ggdb -shared -Wl,-install_name,libmsrp.so.0 -o libmsrp.so.0.0.2 ... etc.
      

      【讨论】:

      • 我尝试了你的想法,但没有奏效。正如您所写,我修改了 Makefile,然后运行“make so”命令。 gcc -ggdb -shared -Wl,-install_name,libmsrp.so.0 -o libmsrp.so.0.0.2 msrp.o msrp_session.o msrp_message.o msrp_relay.o msrp_switch.o msrp_callback.o msrp_network.o msrp_utils.o - Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -lpthread 未定义符号:“_main”,引用自:从 crt1.10.5.o 开始 ld:未找到符号 collect2:ld 返回 1 个退出状态 make:* ** Stack Overflow 错误 1 ​​有什么想法吗?
      • 是的,它确实有效。我下载了软件包,进行了更改,并且编译得很好。您一定更改了其他内容。
      • 我尝试...我删除每个文件并解压缩并重新启动我的 Mac。我从sourceforge.net/projects/libmsrp 站点下载该库。我替换命令: $(CC) -ggdb -shared -Wl,-install_name,libmsrp.so.0 -o libmsrp.so.0.0.2 $(OBJS) $(OPTS) $(LIBS) 编译它:make all ,但我得到同样的错误:未定义的符号:“_main”,引用自:从crt1.10.5.o开始你使用10.5或10.6 os x?我使用 10.5
      • 我使用的是 10.6 和 Xcode 3.2.3。我想这可能是差异。您应该检查您的链接器文档(man ld)以查看设置内部安装路径的选项。
      • 也可以试试gcc -ggdb -shared -Wl,-dylib,-Wl,-install_name,libmrsp.so.0...
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-05
      相关资源
      最近更新 更多