Compile with different compiler? Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
alancan
Earned a small fee
Earned a small fee
Posts: 21
Joined: Mon Jul 26, 2010 1:35 pm

Compile with different compiler?

Post by alancan » Fri Dec 09, 2011 2:35 pm

In short, what I have is a console based project, created in wxDev-C++, that has no wxwidgets included, that I'd like to run on my unix web server - as part of a web application.

The issue that I see, and I could be wrong, is that wxdevc++ compiles with gcc 3.4.5 by default, and the unix web server is still running on gcc 3.3.3. In "your" opinion, what would be the best way to approach this situation using wxDev-C++? Add a compiler to wxDev-C++? Attempt to update the server to use gcc 3.4.5? Create a custom makefile for the server compiler, and compile on the server? It would be beneficial for me, if I could do bug testing in wxDev-C++, and not have to recompile on the server, but this has been the case in past projects.

FYI, the console program was written in wxDev-C++ because it's actually a core program that has a console interface as well as a wxwidgets GUI interface, and so I use wxDev-C++ for both to keep my environment the same.

Thanks for any help or just your opinions.

tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Re: Compile with different compiler?

Post by tbreina » Fri Dec 09, 2011 5:08 pm

There shouldn't be too much of a difference between gcc 3.3.3 and 3.4.5 that would cause an incompatibility. My guess is that if you used gcc 3.4.5 the linker should be able to handle the 3.3.3 compiled stuff just fine. Typically projects maintain backwards compatibility to some extent.

I'm assuming that since this is a unix webserver that you are compiling for unix? Or, are you trying to run your unix webserver on Windows?

-Tony
Everybody's got something to hide except for me and my monkey.

alancan
Earned a small fee
Earned a small fee
Posts: 21
Joined: Mon Jul 26, 2010 1:35 pm

Re: Compile with different compiler?

Post by alancan » Fri Dec 09, 2011 6:36 pm

Well it seems as though it will not run, and it may be because I am compiling on a windows machine and then trying to use that executable to run on the unix machine. I have attempted to change the compiler type to linux gcc, but I end up with an error each time - or it simply does not work on the unix machine. It may be the default location for linux gcc makefile (which is /usr/bin/make, and I obviously don't have that location on my windows machine), got stuck there yesterday, so I didn't go much further. This is the error:

Code: Select all

[Resource Error] able to run "/usr/bin/make -f "Makefile.win" all ": The system cannot find the path specified
I wrote a custom Makefile to run on the unix server (which is entirely a unix server, not running through windows), and I can compile the project fine - just had to fix some paths.

Thanks for responding, but not 100% sure where to go yet. Any ideas are appreciated.

tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Re: Compile with different compiler?

Post by tbreina » Sat Dec 10, 2011 2:44 am

alancan wrote:Well it seems as though it will not run, and it may be because I am compiling on a windows machine and then trying to use that executable to run on the unix machine. I have attempted to change the compiler type to linux gcc, but I end up with an error each time - or it simply does not work on the unix machine. It may be the default location for linux gcc makefile (which is /usr/bin/make, and I obviously don't have that location on my windows machine), got stuck there yesterday, so I didn't go much further. This is the error:

Code: Select all

[Resource Error] able to run "/usr/bin/make -f "Makefile.win" all ": The system cannot find the path specified
I wrote a custom Makefile to run on the unix server (which is entirely a unix server, not running through windows), and I can compile the project fine - just had to fix some paths.

Thanks for responding, but not 100% sure where to go yet. Any ideas are appreciated.
Ok. I'm not 100% understanding your scenario, but I'll go with what I think you are attempting to do (and you can correct me as necessary).

You won't be able to take your Windows .exe and run it on Linux unless you are using it under something like Wine. I think there is a way for the gcc compiler to cross-compile your project (so that you can compile it on Windows for execution on Linux), however, I've never done that.

Assuming you want everything to run under Linux, your best bet is to copy your project over to your Linux machine and compile it on that machine. You'll need to make sure that you have g++ and wxWidgets installed on the Linux machine (which can usually be grabbed from an rpm package). I thought I had set the "Default Linux gcc compiler" profile up correctly, but it appears to have some extraneous directories. However, your makefile for Linux should look something like this:

Code: Select all

# Project: Project1
# Compiler: Default Linux gcc compiler
# Compiler Type: Linux gcc
# Makefile created by wxDev-C++ wxDev-C++ IDE 7.4.1.13 on 09/12/11 18:39

CPP       = gcc
CC        = gcc
WINDRES   = 
OBJ       = linux_build/Project1App.o linux_build/Project1Frm.o
LINKOBJ   = "linux test/Project1App.o" "linux test/Project1Frm.o"
LIBS      = `wx-config --libs`  
INCS      =
CXXINCS   =
RCINCS    =
BIN       = linux_build/Project1
DEFINES   = 
CXXFLAGS  = $(CXXINCS) $(DEFINES) `wx-config --cxxflags`   -fexpensive-optimizations -O3
CFLAGS    = $(INCS) $(DEFINES)   -fexpensive-optimizations -O3
GPROF     = gprof
RM        = rm -f
LINK      = gcc

.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after

clean: clean-custom
	$(RM) $(LINKOBJ) "$(BIN)"

$(BIN): $(OBJ)
	$(LINK) $(LINKOBJ) -o "$(BIN)" $(LIBS) 

linux_build/Project1App.o: $(GLOBALDEPS) Project1App.cpp Project1App.h Project1Frm.h
	$(CPP) -c Project1App.cpp -o "linux test/Project1App.o" $(CXXFLAGS)

linux_build/Project1Frm.o: $(GLOBALDEPS) Project1Frm.cpp Project1Frm.h
	$(CPP) -c Project1Frm.cpp -o "linux test/Project1Frm.o" $(CXXFLAGS)
Note that you run this makefile on your Linux machine (not from wxDev-C++ in Windows). So you'll copy the project files over, edit the makefile as per above, and then-- from the Linux shell-- run "make -f Makefile all". That will invoke make and gcc on the Linux machine (which is usually under something like /usr/bin).

-Tony
Everybody's got something to hide except for me and my monkey.

alancan
Earned a small fee
Earned a small fee
Posts: 21
Joined: Mon Jul 26, 2010 1:35 pm

Re: Compile with different compiler?

Post by alancan » Mon Dec 12, 2011 1:12 pm

Tony,

Essentially what you described (create a makefile for the linux machine), and run that on the linux server is what I'm doing now.

When you spoke of gcc cross-compiling, that is what I was trying to achieve, but I think I will simply stick with the linux makefile that I have been using. When I have more time, will put some more in to the cross-compiling issue.

Thanks,

Alan

Post Reply