Max Frai
Max Frai

Reputation: 64356

Build cpp application

I have a list of files (cpp, h, and also child-folders inside with cpp/h too).

I'm not sure how to build it correctly because it doesn't have any makefile or smth like that (pure c++-files). So I decided to "catch" the right gcc arguments to build it.

g++ *.cpp `wx-config --libs` `wx-config --cxxflags` -lGL -lglut -lfkr-skeletal2d

Now I have that line. Here is the list of files:

$ ls -p
AnimationEditor/  Core-Code/  GLRender.cpp  GLSprite.cpp  Icons/         LGPLv3.txt      MainWindow.h  PlayBar.h  PopUp.h       TimeLine.h
BoneEditor/       daten/      GLRender.h    GLSprite.h    LGPLv3_de.txt  MainWindow.cpp  PlayBar.cpp   PopUp.cpp  TimeLine.cpp  wxWidgets_Addons/

There is files in directory Core-Code:

AnimationManager.cpp  AnimationManager.h  SkeletalManager.cpp  SkeletalManager.h  TextureManager.cpp  TextureManager.h

When I use that gcc-line I get a lot of linker errors:

undefined reference to `CSkeletalManager::***
undefined reference to `CAnimationManager::***

Maybe, I have to specify somehow the files from Core-Code. I can't understand the problem.

Upvotes: 1

Views: 207

Answers (2)

Drakosha
Drakosha

Reputation: 12165

I'd add also: Core-Code/*.cpp to the command line.

Upvotes: 1

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81724

The best thing to do would be to put in a little effort and actually create a set of Makefiles; a top-level one, and child Makefiles for the subdirectories. But if you want to use your same approach of just creating a command line, start by replacing your '*.cpp' with find . -name '*.cpp' so that it includes all the *.cpp files. I think after that you'll have problems finding *.hpp files, so you'll need to add some -I options to tell g++ where to look for the headers.

So something like

g++ `find . -name '*.cpp'` -IAnimationEditor -IBoneEdiror -ICore-Code `wx-config --libs` `wx-config --cxxflags` -lGL -lglut -lfkr-skeletal2d

Upvotes: 2

Related Questions