Error linking to molmodel
Posted: Sun Jun 21, 2015 5:43 am
Hi Sherm,
I'm sure the answer to this problem is staring me in the face, but I have hacked at it for a while without success. I am trying to write a little program that uses PdbStructure(std::istream&), among other molmodel functions. However at link time I am told that the corresponding symbol does not exist for this architecture. I can use other polymorphisms of PdbStructure without inducing this error. It is almost as though I were linking to an old binary that lacked this polymorphism, but my makefile is so simple as to make this almost impossible, plus I think this constructor has existed for a long time.
here is my only program file, generate-base-pair-transform.cpp :
1 #include <iostream>
2 #include <fstream>
3 #include "SimTKmolmodel.h"
4
5 using namespace std;
6 using namespace SimTK;
7
9 int main () {
10 std::filebuf fb;
11 fb.open ("1MSY.pdb",std::ios::in);
12 std::istream myPdbFile(&fb);
14 RNA myRNA ("AAA");
17 PdbStructure myPdbStructure( myPdbFile);
22 return 0;
23 }
And here is my Makefile:
generate-base-pair-transform.o : ../src/generate-base-pair-transform.cpp
g++ -o generate-base-pair-transform.o -c ../src/generate-base-pair-transform.cpp -I/usr/local/SimTK/include/molmodel/internal -I/usr/local/SimTK/
include -I/usr/local/SimTK/include/simbody/ -I/usr/include/c++/4.2.1 -arch x86_64
#-arch was i386
generate-base-pair-transform : generate-base-pair-transform.o
g++ -o generate-base-pair-transform generate-base-pair-transform.o -I/usr/local/SimTK/include/SimTKcommon/internal -I/usr/local/SimTK/include/molmodel/internal -I/usr/local/SimTK/include -L/usr/local/SimTK/lib -lSimTKcommon -lSimTKmolmodel -lSimTKsimbody -lSimTKmath -llapack -lblas -arch x86_64
Compiling generate-base-pair-transform.o goes fine. Here is what happens at link time:
samuelfressmbp3:build Sam$ make generate-base-pair-transform
g++ -o generate-base-pair-transform generate-base-pair-transform.o -I/usr/local/SimTK/include/SimTKcommon/internal -I/usr/local/SimTK/include/molmodel/internal -I/usr/local/SimTK/include -L/usr/local/SimTK/lib -lSimTKcommon -lSimTKmolmodel -lSimTKsimbody -lSimTKmath -llapack -lblas -arch x86_64
Undefined symbols for architecture x86_64:
"SimTK::PdbStructure::PdbStructure(std::istream&)", referenced from:
_main in generate-base-pair-transform.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [generate-base-pair-transform] Error 1
Any ideas?
Many thanks
Sam
I'm sure the answer to this problem is staring me in the face, but I have hacked at it for a while without success. I am trying to write a little program that uses PdbStructure(std::istream&), among other molmodel functions. However at link time I am told that the corresponding symbol does not exist for this architecture. I can use other polymorphisms of PdbStructure without inducing this error. It is almost as though I were linking to an old binary that lacked this polymorphism, but my makefile is so simple as to make this almost impossible, plus I think this constructor has existed for a long time.
here is my only program file, generate-base-pair-transform.cpp :
1 #include <iostream>
2 #include <fstream>
3 #include "SimTKmolmodel.h"
4
5 using namespace std;
6 using namespace SimTK;
7
9 int main () {
10 std::filebuf fb;
11 fb.open ("1MSY.pdb",std::ios::in);
12 std::istream myPdbFile(&fb);
14 RNA myRNA ("AAA");
17 PdbStructure myPdbStructure( myPdbFile);
22 return 0;
23 }
And here is my Makefile:
generate-base-pair-transform.o : ../src/generate-base-pair-transform.cpp
g++ -o generate-base-pair-transform.o -c ../src/generate-base-pair-transform.cpp -I/usr/local/SimTK/include/molmodel/internal -I/usr/local/SimTK/
include -I/usr/local/SimTK/include/simbody/ -I/usr/include/c++/4.2.1 -arch x86_64
#-arch was i386
generate-base-pair-transform : generate-base-pair-transform.o
g++ -o generate-base-pair-transform generate-base-pair-transform.o -I/usr/local/SimTK/include/SimTKcommon/internal -I/usr/local/SimTK/include/molmodel/internal -I/usr/local/SimTK/include -L/usr/local/SimTK/lib -lSimTKcommon -lSimTKmolmodel -lSimTKsimbody -lSimTKmath -llapack -lblas -arch x86_64
Compiling generate-base-pair-transform.o goes fine. Here is what happens at link time:
samuelfressmbp3:build Sam$ make generate-base-pair-transform
g++ -o generate-base-pair-transform generate-base-pair-transform.o -I/usr/local/SimTK/include/SimTKcommon/internal -I/usr/local/SimTK/include/molmodel/internal -I/usr/local/SimTK/include -L/usr/local/SimTK/lib -lSimTKcommon -lSimTKmolmodel -lSimTKsimbody -lSimTKmath -llapack -lblas -arch x86_64
Undefined symbols for architecture x86_64:
"SimTK::PdbStructure::PdbStructure(std::istream&)", referenced from:
_main in generate-base-pair-transform.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [generate-base-pair-transform] Error 1
Any ideas?
Many thanks
Sam