我在Windows 7下在Cygwin中安装了 SystemC(2.3.2)和 SystemC-AMS(2.1),而没有出现以下问题:
./configure --with-systemc=/home/user/Workspace/systemc-2.3.2
make
make install
然后我进入Eclipse(Photon-4.8.0)并创建了一个新的C / C ++项目。对于工具链,我选择了Cygwin GCC
。此外,我在项目中应用了以下设置:
包含路径:
"C:\cygwin64\home\user\Workspace\systemc-2.3.2\include"
"C:\cygwin64\home\user\Workspace\systemc-ams-2.1\include"
图书馆搜索路径:
"C:\cygwin64\home\user\Workspace\systemc-2.3.2\lib-cygwin64"
"C:\cygwin64\home\user\Workspace\systemc-ams-2.1\lib-cygwin64"
图书馆:
systemc
systemc-ams
现在,我尝试执行以下代码:
#include <iostream>
#include "systemc.h"
#include "systemc-ams.h"
int sc_main (int argc, char* argv[])
{
std::cout << "Hello World" << std::endl;
sca_tdf::sca_signal <double> out1;
return 0;
}
我收到未定义的引用错误:
11:36:35 **** Incremental Build of configuration Debug for project SystemC-AMS-Test ****
make all
Building file: ../TestSCAMS.cpp
Invoking: Cygwin C++ Compiler
g++ -I"C:\cygwin64\home\user\Workspace\systemc-2.3.2\include" -I"C:\cygwin64\home\user\Workspace\systemc-ams-2.1\include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"TestSCAMS.d" -MT"TestSCAMS.o" -o "TestSCAMS.o" "../TestSCAMS.cpp"
Finished building: ../TestSCAMS.cpp
Building target: SystemC-AMS-Test.exe
Invoking: Cygwin C++ Linker
g++ -L"C:\cygwin64\home\user\Workspace\systemc-2.3.2\lib-cygwin64" -L"C:\cygwin64\home\user\Workspace\systemc-ams-2.1\lib-cygwin64" -o "SystemC-AMS-Test.exe" ./TestSCAMS.o -lsystemc -lsystemc-ams
C:\cygwin64\home\user\Workspace\systemc-ams-2.1\lib-cygwin64/libsystemc-ams.a(convert_from_string.o):convert_from_string.cpp:(.text$_ZN8sca_util18sca_implementation18convert_by_istreamIN5sc_dt8sc_logicEEEbRT_RKSs[_ZN8sca_util18sca_implementation18convert_by_istreamIN5sc_dt8sc_logicEEEbRT_RKSs]+0x18f): undefined reference to `sc_dt::sc_logic::scan(std::istream&)'
C:\cygwin64\home\user\Workspace\systemc-ams-2.1\lib-cygwin64/libsystemc-ams.a(convert_from_string.o):convert_from_string.cpp:(.text$_ZN8sca_util18sca_implementation18convert_by_istreamIN5sc_dt8sc_logicEEEbRT_RKSs[_ZN8sca_util18sca_implementation18convert_by_istreamIN5sc_dt8sc_logicEEEbRT_RKSs]+0x18f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `sc_dt::sc_logic::scan(std::istream&)'
collect2: error: ld returned 1 exit status
make: *** [makefile:46: SystemC-AMS-Test.exe] Error 1
11:36:38 Build Failed. 1 errors, 0 warnings. (took 3s.199ms)
这里可能是什么问题?
答案 0 :(得分:1)
在某些平台上,例如Windows,cygwin和其他未定义的符号,在链接阶段是不允许的。
链接顺序很重要
"-lsystemc -lsystemc-ams"
与" -lsystemc-ams -lsystemc"
当systemc-ams
使用systemc
的符号时,第二个版本保证所有符号都在链接阶段解析。
这也是编译库调用的程序位于命令末尾的原因。
gcc dummy.c -lsystemc
有效,而gcc -lsystemc dummy.c
失败并出现undefined symbols
错误