Page 1 of 1

Compile new apps?

Posted: Wed Apr 09, 2014 2:17 pm
by AngelGM
Hi all,

I use ubuntu.

I built the code OK. And the demos run perfectly. Now, how do I compile a new cpp file? I have tried in /Demo and in the root folder, but I do not know how to compile a very easy cpp that uses bullet.

Just that simple thing.

Many thanks.
A

Re: Compile new apps?

Posted: Thu Apr 10, 2014 2:52 am
by Basroil
AngelGM wrote: I built the code OK. And the demos run perfectly. Now, how do I compile a new cpp file? I have tried in /Demo and in the root folder, but I do not know how to compile a very easy cpp that uses bullet.

Just that simple thing.
I would have expected most linux users to have a working knowledge of programming and compilers, since using programs on linux means compiling programs :?

Check online for one of those "Dumbies guide" type tutorial on getting started with C and C++ compilers. It's not intended as an insult, rather that those guides are probably the single fastest way to achieve what you are looking for.

Re: Compile new apps?

Posted: Thu Apr 10, 2014 7:49 am
by AngelGM
Wow! Very constructive reply...

I copy the /src folder (its contents) after building to a new app folder. When building my new.cpp I cannot link the h files. The demos work fine, so I know it is a little easy thing and I would really appreciate if someone could please tell me.

Thanks,
A

Re: Compile new apps?

Posted: Thu Apr 10, 2014 9:33 am
by AngelGM
Found it!

This is solved in: http://ubuntuforums.org/showthread.php?t=2104517

I had to compile with: g++ $(pkg-config --cflags bullet) file.cpp $(pkg-config --libs bullet)

Thanks,
A

Re: Compile new apps?

Posted: Thu Apr 10, 2014 3:39 pm
by AngelGM
Hi all again,

OK, I do really need some more help here.

Current state: I've got bullet built and I can run the demos perfectly.

Need: I want to start a new bullet project in linux (not using any GUI).

Problem: I cannot compile my project neither any demo outside its original folder. I create a /project folder and copy the /src in there. If my new project contains

Code: Select all

#include <btBulletDynamicsCommon.h>
I have to compile it with

Code: Select all

$(pkg-config --cflags bullet) file.cpp $(pkg-config --libs bullet)
. If I include any Glut .h file I have to compile linking to them with -I ../Demos/OpenGL/. No errors here, but if I try to go further, the errors start. As a test I copied the /Demo/BasicDemo/ folder (as it came just after download) into my new /project and try to make/run it from here: fail.

Question: How can I compile the BasicDemo outside its original folder?. Let's say, in a new /project folder I just created in /bullet-2.83-r2704? If I can compile it, I will understand the needs of my new .cpp file.

Many thanks,
A

Re: Compile new apps?

Posted: Sat Apr 12, 2014 7:59 am
by Basroil
AngelGM wrote: Question: How can I compile the BasicDemo outside its original folder?. Let's say, in a new /project folder I just created in /bullet-2.83-r2704? If I can compile it, I will understand the needs of my new .cpp file.
Answer: This is not a Bullet issue, rather a C++ programming / compiling one. You really need to look at documentation for your specific compiler to see how to set up proper file management. For all compilers you can simply put the whole path when needed, but most also offer options to add include paths.

I stand by my suggestion for one of the "dummy" books (not necessarily the brand, but other beginner oriented ones too), I regularly suggest them to friends, and sarcasm is not appreciated when I literally gave you the best answer available at the time (since you never specified anything about your environment or compiler choice) :roll:

Re: Compile new apps?

Posted: Mon Apr 14, 2014 11:08 am
by AngelGM
OK, thanks. I'll do as you say.

<EDIT>
Meanwhile, it will be great if you could answer this:

If you copy the BasicDemo files into a bullet2.82-r2704/new_folder, what is the command you would use to compile it? (i.e. g++...). I use linux Debian.

Cheers,
A

Re: Compile new apps?

Posted: Tue Apr 15, 2014 2:49 am
by Basroil
I don't use debian for bullet (use bullet in conjunction with drivers and software that is Windows only), but If you replace the paths as needed and update library paths if needed (and as I stated already), it should work on any platform that bullet is supported on (i.e. not 8bit ATMega or 16bit H8). As for how to do that, buy a book or read an online manual, you're going to be needing the experience, and just giving you the information is going to impede your learning :wink:

Re: Compile new apps?

Posted: Tue Apr 15, 2014 10:57 am
by AngelGM
Done,

You must have in mind the three CMakeLists.txt that are important:
- The one in the bullet folder
- The one inside the Demos folder
- The one inside each demo folder

By changing the links in them you can basically place your project wherever you want in your machine and then build it with cmake from the bullet folder. Rather than trying to compile your code in a single line (g++ ...) which is a nightmare (at least for me, that never had a book for dummies) it is much better to modify those three cmake files depending on your needs. That way you can skip using any software; and your favourite text editor and the terminal are the only things you need.

Cheers,
A

PS. Basroil, your answers are extremely useful.