user14699620
user14699620

Reputation:

WxWidgets || Creating makefile

I'm trying to compile my program using makefile.

My code:

zad2_1Main: zad2_1Main.o zad2_1App.o
    g++ -o zad2_1Main zad2_1Main.o zad2_1App.o wx-config.exe --cxxflags

zad2_1Main.o: zad2_1Main.cpp
    g++ -c zad2_1Main.cpp wx-config.exe wx-config.exe --cxxflags

zad2_1App.o: zad2_1App.cpp
    g++ -c zad2_1App.cpp wx-config.exe wx-config.exe --cxxflags

But i have error:

unrecognized command line option '--cxxflags'

wx-config.exe is in the same folder as the files

My files:

Zad2_1App.cpp
Zad2_1App.h
Zad2_1Main.cpp
Zad2_1Main.h

Upvotes: 0

Views: 636

Answers (2)

VZ.
VZ.

Reputation: 22688

You want to pass the output of wx-config to the compiler, not the literal string itself. Moreover, it's pretty wasteful to run the shell script again and again for each and every source file. So instead you should do the following:

WX_CXXFLAGS := $(shell wx-config --cxxflags)
WX_LIBS := $(shell wx-config --libs)

zad2_1Main: zad2_1Main.o zad2_1App.o
    g++ -o zad2_1Main zad2_1Main.o zad2_1App.o $(WX_LIBS)

zad2_1Main.o: zad2_1Main.cpp
    g++ -c zad2_1Main.cpp $(WX_CXXFLAGS)

zad2_1App.o: zad2_1App.cpp
    g++ -c zad2_1App.cpp $(WX_CXXFLAGS)

Your makefile could be improved in several other ways, but this should at least work.

Upvotes: 1

Igor
Igor

Reputation: 6255

@Tacoo.

You should use backticks around wx-config --cxxflags and wx-config --libs.

Something like

g++ -o zad2_1Main zad2_1Main.o zad2_1App.o `wx-config.exe --cxxflags`

Upvotes: 0

Related Questions