Tag: undefined symbol

对solaris的ppoll

这段代码在Linux中编译但不在Solaris中编译,因为显然ppoll()是特定于Linux的(我在Solaris中使用GCC得到了一个未定义的符号错误)。 有任何帮助转换吗? 我不认为只使用poll()是一个好主意,但话说回来,我没有编写这段代码。 (我是用C编写命令行shell的;第一次尝试使用ncurses / C ) #include #include #include #include #include #include #include #include /** VT100 command to clear the screen. Use puts(VT100_CLEAR_SCREEN) to clear * the screen. */ #define VT100_CLEAR_SCREEN “\033[2J” /** VT100 command to reset the cursor to the top left hand corner of the * screen. */ #define VT100_CURSOR_TO_ORIGIN “\033[H” struct […]

如何使用编译的C代码编译和链接C ++代码?

我希望能够使用Cmockery来模拟从我正在测试的C ++代码调用的C函数。 作为向前迈出的一步,我将Cmockery示例run_tests.c重命名为run_tests.cpp,并尝试编译并将其与cmockery.c链接: g++ -m32 -DHAVE_CONFIG_H -DPIC -I ../cmockery-0.1.2 -I /usr/include/malloc -c run_tests.cpp -o obj/run_tests.o gcc -m32 -DHAVE_CONFIG_H -DPIC -Wno-format -I ../cmockery-0.1.2 -I /usr/include/malloc -c ../cmockery-0.1.2/cmockery.c -o obj/cmockery.o g++ -m32 -o run_tests obj/run_tests.o obj/cmockery.o 前两个命令行(编译)是成功的,但在最后我得到: Undefined symbols: “_run_tests(UnitTest const*, unsigned long)”, referenced from: _main in run_tests.o ld: symbol(s) not found collect2: ld returned 1 exit […]

编译内核模块时,“__aeabi_ldivmod”未定义

我正在尝试在raspberry pi上编译一个内核模块(我自己编写)。 我正在目标环境中编译它。 我得到以下输出: make -C /lib/modules/3.12.23-1.20140626git25673c3.rpfr20.armv6hl.bcm2708/build M=/home/harmic/horus/ppminput modules make[1]: Entering directory `/usr/src/kernels/3.12.23-1.20140626git25673c3.rpfr20.armv6hl.bcm2708′ CC [M] /home/harmic/horus/ppminput/ppminput.o Building modules, stage 2. MODPOST 1 modules WARNING: “__aeabi_ldivmod” [/home/harmic/horus/ppminput/ppminput.ko] undefined! CC /home/harmic/horus/ppminput/ppminput.mod.o LD [M] /home/harmic/horus/ppminput/ppminput.ko make[1]: Leaving directory `/usr/src/kernels/3.12.23-1.20140626git25673c3.rpfr20.armv6hl.bcm2708′ 果然,如果我尝试插入模块,我得到: insmod: ERROR: could not insert module ./ppminput.ko: Unknown symbol in module 在syslog中: Sep 2 22:44:26 pidora kernel: [ […]

使用头文件时未定义的符号错误

我收到了以下错误,并且不能为我的生活弄清楚我做错了什么。 $ gcc main.c -o main Undefined symbols: “_wtf”, referenced from: _main in ccu2Qr2V.o ld: symbol(s) not found collect2: ld returned 1 exit status main.c中: #include #include “wtf.h” main(){ wtf(); } wtf.h: void wtf(); wtf.c: void wtf(){ printf(“I never see the light of day.”); } 现在,如果我将整个函数包含在头文件中而不仅仅是签名中,那么它就符合要求,因此我知道wtf.h被包含在内。 为什么编译器看不到wtf.c? 或者我错过了什么? 问候。