0
votes

I've been having some difficulty compiling a piece of C++ code for the physics engine Bullet Physics, and was hoping to get some advice.

This is my first time using gcc as a compiler, and including directories for compiling in general, so I'm going to give my whole process of problem-solving because I'm not sure where I went wrong or what the pertinent information is.

When I first tried to compile the code I got a fatal error about "No such error or directory", so I decided to add the directory with the -I option (1). It fixed the first error, but another popped up. Again, I was able to make the error go away with a -I option to the directory needed(2).

Then I got a whole long list of errors like the following:

main.cpp:(.text+0x33): undefined reference to 'RagdollDemo::initPhysics()'

main.cpp:(.text+0x84): undefined reference to 'glutmain(int, char**, int, int, char const*, DemoApplication*)'

/tmp/cc4MqhHm.o: In function '__static_initialization_and_destruction_0(int, int)': main.cpp:(.text+0xe7): undefined reference to `std::ios_base::Init::Init()'

I tried a few different things, but the solution ended up using my home bullet folder (or usr/local/include/bullet/) with the --sysroot option (3).

This created a lot of errors for the C++ header files, and then I linked to a few more directories with -I (4-5), but at after one of the added directories the same set of errors that I thought I solved with the --sysroot addition popped up again (6).

I can't tell what to do now. I would guess that declaring the bullet folder as my root makes it impossible for the compiler to find the required C++ files in my actual root directories, but I don't what to do about that... and when I tried including the C++ files I needed, the compiler seemingly forgot I told it to use bullet as my root.

Final compilation I tried before I gave up and realized asking for help might be better than spending 3 hours looking at documentation without any idea of what the exact problem is. Numbers correspond to the steps above.

gcc (3)--sysroot=/home/josh/bullet-2.82-r2704/ (1)-isystem/home/josh/bullet-2.82-r2704/Demos/OpenGL/ (2)-isystem/home/josh/bullet-2.82-r2704/src/ (4)-I/usr/include/ (5)-I/usr/include/c++/4.8 (6)-I/usr/include/x86_64-linux-gnu/c++/4.8/ ./main.cpp

I'm using Ubuntu 14.04 LTS and my OS and emacs 24.3.1 as my IDE.

Any help would be greatly appreciated.

Best, Josh

1
Looks like linker problems. Did you add the libs to the linkpath?eckes
@eckes, thanks for the comment. I added the appropriate libraries and it compiled fine.KodoCoder
@RetoKoradi, it is... does that mean I should delete the question?KodoCoder

1 Answers

0
votes

What you are seeing is not include issue. Linker is failing to link with symbols. You need to link with proper library, for example lglut