News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Trying to import a MingW/GCC project

Started by Viper187, March 20, 2013, 06:56:37 PM

Previous topic - Next topic

Viper187

Running Win7, just installed the current version of Code::Blocks (mingw installer). I've been writing my source in Textpad and just compiling with mingw's msys environment for a while now since I got tired of Dev-C++. My problem is I have a project with a bunch of files that compiles fine with mingw, but I can't seem to get a Code::Blocks project started with all these files to actually compile. I tried adding them all and compiling, but after running mingw32-gcc.exe to build all the obj files, it tries to use mingw32-g++ and just stops. It shouldn't even need mingw32-g++ for this; mingw only used gcc.exe and windres.exe. The default compiler is set to GNU GCC Compiler. I tried setting it to use my original MakeFile, but it complained a that not having a "Debug target." It really shouldn't be this difficult to load up my existing project and make it compile.


mingw32-gcc.exe -Wall  -g     -c H:\Private\gsctoolz2k\c\RenegadeEX2-CB\tab_settings.c -o obj\Debug\tab_settings.o
mingw32-g++.exe  -o "bin\Debug\Renegade EX2.exe" obj\Debug\lib_api.o obj\Debug\lib_api.o obj\Debug\lib_fileio.o obj\Debug\lib_listview.o obj\Debug\lib_memory.o obj\Debug\lib_misc.o obj\Debug\lib_rex.o obj\Debug\lib_search.o obj\Debug\rex.o obj\Debug\tab_hook.o obj\Debug\tab_results.o obj\Debug\tab_search.o obj\Debug\tab_settings.o  obj\Debug\rex.res   -lgdi32 -luser32 -lkernel32 -lcomctl32
Execution of 'mingw32-g++.exe  -o "bin\Debug\Renegade EX2.exe" obj\Debug\lib_api.o obj\Debug\lib_api.o obj\Debug\lib_fileio.o obj\Debug\lib_listview.o obj\Debug\lib_memory.o obj\Debug\lib_misc.o obj\Debug\lib_rex.o obj\Debug\lib_search.o obj\Debug\rex.o obj\Debug\tab_hook.o obj\Debug\tab_results.o obj\Debug\tab_search.o obj\Debug\tab_settings.o  obj\Debug\rex.res   -lgdi32 -luser32 -lkernel32 -lcomctl32' in 'H:\Private\gsctoolz2k\c\RenegadeEX2-CB\Renegade EX2' failed.
Nothing to be done (all items are up-to-date).


My original makefile:

# Project: RenegadeEx

NAME  = rex.exe

CC = gcc
WINDRES = windres
RES  = rex.res
OBJ  = rex.o tab_hook.o tab_results.o tab_search.o tab_settings.o lib_api.o lib_fileio.o lib_listview.o lib_misc.o lib_rex.o lib_search.o lib_memory.o $(RES)
LDFLAGS = -s -mwindows -lwsock32 -lcomctl32 -lpsapi
CFLAGS = -O2 -s


.PHONY: all

all: $(NAME)


clean:
rm -f $(OBJ)

$(NAME): $(OBJ)
$(CC) $(OBJ) -o $(NAME) $(LDFLAGS)

rex.res: rex.rc rex_gui.h
$(WINDRES) -i rex.rc -J rc -o rex.res -O coff

rex.o: rex.c rex.h rex_gui.h _types.h
$(CC) -c rex.c -o rex.o $(CFLAGS)

#Tabs

tab_hook.o: tab_hook.c rex.h rex_gui.h _types.h
$(CC) -c tab_hook.c -o tab_hook.o $(CFLAGS)

tab_results.o: tab_results.c rex.h rex_gui.h _types.h
$(CC) -c tab_results.c -o tab_results.o $(CFLAGS)

tab_search.o: tab_search.c rex.h rex_gui.h _types.h
$(CC) -c tab_search.c -o tab_search.o $(CFLAGS)

tab_settings.o: tab_settings.c rex.h rex_gui.h _types.h
$(CC) -c tab_settings.c -o tab_settings.o $(CFLAGS)

#Libraries

lib_api.o: lib_api.c rex.h _types.h
$(CC) -c lib_api.c -o lib_api.o $(CFLAGS)

lib_fileio.o: lib_fileio.c rex.h _types.h
$(CC) -c lib_fileio.c -o lib_fileio.o $(CFLAGS)

lib_listview.o: lib_listview.c rex.h _types.h
$(CC) -c lib_listview.c -o lib_listview.o $(CFLAGS)

lib_memory.o: lib_memory.c rex.h _types.h
$(CC) -c lib_memory.c -o lib_memory.o $(CFLAGS)

lib_misc.o: lib_misc.c lib_misc.h rex.h _types.h
$(CC) -c lib_misc.c -o lib_misc.o $(CFLAGS)

lib_rex.o: lib_rex.c rex.h _types.h
$(CC) -c lib_rex.c -o lib_rex.o $(CFLAGS)

lib_search.o: lib_search.c lib_search.h rex.h _types.h
$(CC) -c lib_search.c -o lib_search.o $(CFLAGS)


stahta01

#1
Add the below lines to your make file is the fastest solution to get CB Debug target to build (using a custom makefile).
(You can also change Code::Blocks to match your makefile; but, I find it easier to change the makefile to match CB)


Debug: $(NAME)

cleanDebug: clean


The other solution is to compile hello world from the wizard to verify your compiler and CB and setup correctly.
After that try to find what is the problem when what you are trying to do.

Edit: Spaces in EXE filenames is NOT a wise thing to do!

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

oBFusCATed

Quote from: stahta01 on March 21, 2013, 12:03:33 AM
(You can also change Code::Blocks to match your makefile; but, I find it easier to change the makefile to match CB)
In fact there is a hidden tab in the build options, where the user can modify the exact command executed for the different operations
and there is no need to modify the makefiles.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

stahta01

Quote from: oBFusCATed on March 21, 2013, 01:15:08 AM
Quote from: stahta01 on March 21, 2013, 12:03:33 AM
(You can also change Code::Blocks to match your makefile; but, I find it easier to change the makefile to match CB)
In fact there is a hidden tab in the build options, where the user can modify the exact command executed for the different operations
and there is no need to modify the makefiles.

My makefile projects are ran on multiple computers; using different version of CB.
I know about your way; just find it much easier to do it my way.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

oBFusCATed

My way is to use projects, I'm just suggesting that there are options.
Most people aren't comfortable editing makefiles...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Viper187

Well, that was annoying, but it compiles. Turns out after adding those 2 things to the makefile you also have to go in the project settings and tell it what/where the exe will be based on the makefile. It would be much easier if it could at least try to import a simple makefile. It will import Dev-C++ projects, VC++, etc but not just a plain old makefile?

oBFusCATed

You're free to try to write a makefile importer, then try to maintain it for several years.
The amount of incompatibilities will be roughly unacceptable, because I guess there is no such thing as
simple Makefile.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]