在使用新的llvm软件包编译时,我或多或少地检查了这类问题的所有答案,但我找不到任何解决方案。
MacBook-Air-di-Manfredo:SINGLE_TETRAMER manfredo$ clang++ -v -Wall -O3 -g -fpic -c -lm grbyinsertion.cpp -I/Users/manfredo/Desktop/tesi/codice_tesi/oxDNA/src/Observables
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
clang: warning: -lm: 'linker' input unused
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -disable-free -disable-llvm-verifier -main-file-name grbyinsertion.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -gdwarf-2 -coverage-file /Users/manfredo/Desktop/tesi/codice_tesi/SINGLE_TETRAMER/grbyinsertion.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -I /Users/manfredo/Desktop/tesi/codice_tesi/oxDNA/src/Observables -stdlib=libc++ -O3 -Wall -fdeprecated-macro -fdebug-compilation-dir /Users/manfredo/Desktop/tesi/codice_tesi/SINGLE_TETRAMER -ferror-limit 19 -fmessage-length 121 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o grbyinsertion.o -x c++ grbyinsertion.cpp
clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.1.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/Users/manfredo/Desktop/tesi/codice_tesi/oxDNA/src/Observables
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks (framework directory)
End of search list.
grbyinsertion.cpp:63:9: warning: unused variable 'box_side' [-Wunused-variable]
number box_side = *this->_config_info.box_side;
^
grbyinsertion.cpp:156:16: note: in instantiation of member function 'grbyinsertion<float>::init' requested here
template class grbyinsertion<float>;
^
grbyinsertion.cpp:63:9: warning: unused variable 'box_side' [-Wunused-variable]
number box_side = *this->_config_info.box_side;
^
grbyinsertion.cpp:157:16: note: in instantiation of member function 'grbyinsertion<double>::init' requested here
template class grbyinsertion<double>;
^
2 warnings generated.
MacBook-Air-di-Manfredo:SINGLE_TETRAMER manfredo$ clang++ -v -shared -o grbyinsertion.so grbyinsertion.o -g2
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -dylib -arch x86_64 -macosx_version_min 10.9.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -o grbyinsertion.so grbyinsertion.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"_getInputFloat", referenced from:
grbyinsertion<float>::get_settings(input_file&, input_file&) in grbyinsertion.o
grbyinsertion<double>::get_settings(input_file&, input_file&) in grbyinsertion.o
"_getInputInt", referenced from:
grbyinsertion<float>::get_settings(input_file&, input_file&) in grbyinsertion.o
grbyinsertion<double>::get_settings(input_file&, input_file&) in grbyinsertion.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
函数getinputfloat在头文件中定义,如:
int getInputFloat(input_file *inp, const char *skey, float *dest, int mandatory) {
int key = getInputKeyIndex(inp, skey, mandatory);
if(key != KEY_NOT_FOUND) *dest = atof(inp->values[key]);
else return KEY_NOT_FOUND;
return KEY_FOUND;
}
并由我的程序调用如下:
template<typename number>
void grbyinsertion<number>::get_settings(input_file &my_inp, input_file &sim_inp) {
float tmp;
if(getInputFloat(&my_inp, "bin", &tmp, 0) == KEY_FOUND) _bin = tmp;
getInputInt(&my_inp, "insertions", &_insertions, 0);
getInputFloat(&sim_inp, "T", &tmp, 1);
_T = tmp;
if(getInputFloat(&my_inp, "gr_min", &tmp, 0) == KEY_FOUND) _min = tmp;
if(getInputFloat(&my_inp, "gr_max", &tmp, 0) == KEY_FOUND) _max = tmp;
}
我实际上注意到定义了getinputfloat函数的头文件是.c文件,而其他文件的大多数(我认为所有这些)都是.cpp,这可能是问题吗?
我的llvm版本是3.5,我已经升级了所有安装的端口(通过macports)。感谢。