Create makefile for wxwidgets project Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Taacoo
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue Dec 15, 2020 8:41 pm

Create makefile for wxwidgets project

Post by Taacoo »

Hi, I'm trying to link wxwidgets libs and flags to this makefile.

Code: Select all

OBJS	= TESTTApp.o TESTTMain.o
SOURCE	= TESTTApp.cpp TESTTMain.cpp
HEADER	= TESTTApp.h TESTMain.h
OUT	= a.out
CC	 = g++
FLAGS	 = -g -c -Wall wx-config.exe --cxxflags wx-config.exe --libs
LFLAGS	 = 

all: $(OBJS)
	$(CC) -g $(OBJS) -o $(OUT) $(LFLAGS)

TESTTApp.o: TESTTApp.cpp
	$(CC) $(FLAGS) TESTTApp.cpp 

TESTTMain.o: TESTTMain.cpp
	$(CC) $(FLAGS) TESTTMain.cpp 


clean:
	rm -f $(OBJS) $(OUT)

run: $(OUT)
	./$(OUT)
Error:

Code: Select all

g++: error: unrecognized command line option '--cxxflags'
g++: error: unrecognized command line option '--libs'
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Create makefile for wxwidgets project

Post by ONEEYEMAN »

Hi,
You need backticks around wx-config command.

Thank you.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Create makefile for wxwidgets project

Post by Manolo »

Take a look at "minimal" sample (or anyother more complex sample), provided with your wxWidgets sources.
You'll see "makefile.xxx" files used for different compilers. Learn from them.
Taacoo
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue Dec 15, 2020 8:41 pm

Re: Create makefile for wxwidgets project

Post by Taacoo »

Something like this?

Code: Select all

FLAGS	= -g -c -Wall `wx-config --cxxflags` `wx-config --libs`
Still same error
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Create makefile for wxwidgets project

Post by doublemax »

I think the backticks only work under Linux and OSX, not Windows. Do you even have a wx-config.exe? It's not part of wxWidgets and quite unusual to use under Windows.

I can't help with creating makefiles, but a Manolo said, try to use the existing ones as a reference.
Use the source, Luke!
Taacoo
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue Dec 15, 2020 8:41 pm

Re: Create makefile for wxwidgets project

Post by Taacoo »

Of course i have wx-config.exe installed. I hooked them up to windows environment variables to be able to easily call it with the wx-config command, e.g. using CMD.

Okay, I'll try to use examples from the internet because I can't find one in wxwidgets/ samples
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Create makefile for wxwidgets project

Post by ONEEYEMAN »

Hi,
How did you build the library?
DId you use MSYS{2} or just straight up MinGW?

Thank you.
Taacoo
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue Dec 15, 2020 8:41 pm

Re: Create makefile for wxwidgets project

Post by Taacoo »

Hi,
I've downloaded source code from Github(wx-config) and compiled it to exe using command:

Code: Select all

g++ wx-config-win.cpp -s -o wx-config.exe
Mingw compiler is connected from codeblocks installation(PATH environement variables).

Edit 1

I installed wxwidgets latest stable version on Ubuntu, make and mingw compiler.

After typing 'make' in the terminal, errors pop up, e.g.

Code: Select all

wx use_any must be defined
I will install wxwidgets 3.14 (code was written on this version; platform - Windows) and I will let you know.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Create makefile for wxwidgets project

Post by ONEEYEMAN »

Hi,
What are you trying to do?
When you install wxWidgets from standard Ubuntu repository it will not install samples. You need to install them explicitly.
Also - when you install wxWidgets in Linux - wx-config script is installed automatically. You don't have to do anything else.

It calls "wx-config", not "wx-config.exe" - you are working with *nix, therefore no extension.
You also don't need MinGW compiler on *nix - gcc will suffice. Even for cross-compilation. Thats why its called MinGW (Min-imalistic Gcc for Windows).

In order to compile your program on Linux all you need:

1. gcc
2. libtool
3. GTK with all dependencies.
4. wxGTK

When you install wxGTK "wx-config" script will be installed (again not "wx-config.exe").
So all you need to do is:

Code: Select all

1. cd </your/program/source/code/directory>
2. g++ -o <your_program_name> `wx-config --cxxflags --libs`
*nix is completely different OS from Windows and you need to understand that there is no extension there.

When you are on Windows - things might get more complicated, depending whether you will use MSYS{2} or not.

When you are on Windows:

1. Download and install MinGW from you preferred source.
2. Download and unpack wxWidgets-3.1.4.
3. Do the following:

cd c:\wxWidgets-3.1.4\build\msw
mingw-32.exe -f makefile.gcc BUILD=debug
cd </your/program/source/code/directory>
mingw32.exe BUILD=debug -o <your_program_name> *.cpp

You are done.

If you want to - you can look at the c:\wxWidgets-3.1.4\samples\minimal\makefile.gcc and create something like this to compile your software.
That is if you want to be stuck with MinGW.

But you don't have to.

You can install free version of MSVC and just compile your software using provided MSVC solution. Much easier and less hassle.

So to summarize:

1. Windows and Linux are 2 very different OS.
2. You can install wxWidgets on Linux and it will pull all needed dependencies. Nothing else is needed.
3. Compile your software using g++ and installed/provided wx-config script.
4. On Windows either install free version of MSVC or MinGW
5. Compile wxWidgets, then compile you software using EXACLY THE SAME set of options!! (Can't stress that enough - YOU HAVE TO COMPILE BOTH WITH THE SAME SET OF OPTIONS).
6. Enjoy.
7. OSX is more like *nix.
8. On OSX - download Xcode appropriate for your OSX version.
9. Download command line tools and install it (if its not being installed with the Xcode)
10. Download and unpack wxWidgets-3.1.4
11 Do following:
cd ~/wxWidgets-3.1.4
mkdir buildOSX
cd buildOSX
../configure --enable-debug && make
12 Follow the wxWidgets WiKi to create Xcode project for yuor software. Or use provided wxWidgets-3.1.4\samples\minimal\mininmal.xcode.
13. Add the source files, build and run.

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Create makefile for wxwidgets project

Post by PB »

FWIW, on MSW in CodeLite generated makefile, there is

Code: Select all

CXXFLAGS :=  -O2 -Wall $(shell wx-config --cflags) $(Preprocessors)
One probably has to tell wx-config which configuration to use, AFAIK CodeLite uses system environment variable WXCFG, e.g.

Code: Select all

WXCFG:=gcc_lib/mswu
but it should be possible with wx-config parameter

Code: Select all

--wxcfg[=DIR]
Last edited by PB on Fri Jan 08, 2021 10:07 pm, edited 1 time in total.
Taacoo
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue Dec 15, 2020 8:41 pm

Re: Create makefile for wxwidgets project

Post by Taacoo »

Everythinkg works fine now, of course on ubuntu and fresh wxwidgets installation.

Now i'm fighting with .xpm file where i created path to my custom icon.

Icon work's, but how i can link it to makefile?

Code: Select all

Kompresja_GZIPApp.cpp: In member function ‘virtual bool Kompresja_GZIPApp::OnInit()’:
Kompresja_GZIPApp.cpp:27:28: error: ‘GZIPICON_xpm’ was not declared in this scope
   27 |      Frame->SetIcon(wxICON(GZIPICON));
Post Reply