The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Makefile problem - How to run module load in a Makefile hernandinho UNIX for Advanced & Expert Users 2 04-13-2009 11:20 AM
Makefile myle High Level Programming 0 07-02-2008 10:52 AM
Makefile NamrataGurav High Level Programming 7 10-07-2006 03:29 PM
about the makefile ligerdave High Level Programming 2 01-31-2006 01:21 AM
makefile ECBROWN UNIX for Dummies Questions & Answers 4 02-17-2005 12:01 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-24-2009
TriKri TriKri is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 4
Makefile help

I've copied a C++ project from my old computer to this one, and I am now trying to (without success) compile the project in the same way as I did before. I use Emacs as a text editor and compile with g++. Here is what my makefile looks like:


Code:
CC=g++
CPPFLAGS=-Wall
CPPFLAGS+=-I..
CPPFLAGS+=-lmingw32 -lSDLmain -lSDL
CPPFLAGS+=-mwindows
SRC=main.cpp #../imanip/imanip.cpp #../imanip/imfuncs.cpp
OBJ=$(SRC:.cpp=.o)
OUT=image_test.exe

all: $(OUT)
    rm $(OBJ) #Remove .o

$(OBJ) :
    $(CC) $(SRC) $(CPPFLAGS) -c #Create .o

$(OUT) : $(OBJ)
    $(CC) $(OBJ) $(CPPFLAGS) -o $@ #Link .

And here is what Emacs displays when trying to compile (Edit: just ignore this error and skip down to my second post, since this error was caused by an incorrect installation of SDL!):


Code:
mingw32-make -k 
g++ main.o -Wall -I.. -lmingw32 -lSDLmain -lSDL -mwindows -o image_test.exe
C:\Program1\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lSDLmain
collect2: ld returned 1 exit status
mingw32-make: *** [image_test.exe] Error 1
mingw32-make: Target `all' not remade because of errors.

It says that it can't find -lSDLmain. What does it mean (makefiles are not my strong side), I have installed SDL the way it should be installed (NOT!)? Can you see what is wrong?

Last edited by TriKri; 09-24-2009 at 03:03 AM..
  #2 (permalink)  
Old 09-24-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,972
Check 2 things: Did you install the development package of SDL too, and can it be found in the library search path?
  #3 (permalink)  
Old 09-24-2009
TriKri TriKri is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 4
Sorry, I just realized that SDL was causing that problem, since I copied the wrong folder by mistake when installing SDL development package (bin folder instead of lib).

Anyway, I corrected that, and that error disappeared. However, I got this error instead:


Code:
mingw32-make -k 
g++ main.o -Wall -I.. -lmingw32 -lSDLmain -lSDL -mwindows -o image_test.exe #Link .
g++: #Link: No such file or directory
mingw32-make: *** [image_test.exe] Error 1
mingw32-make: Target `all' not remade because of errors.

Looks like it has problems with the comment? Why? Shouldn't it totally ignore the comment?

Once again, I am a newbie when it comes to makefiles, this one I basically just tried to mimic from an already existing makefile from another project!

Edit: The strange this is that, if I remove the comment "#Link .", it DOES compile, but it leaves the following message:


Code:
mingw32-make -k 
rm main.o #Remove .o
process_begin: CreateProcess(NULL, rm main.o #Remove .o, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make: *** [all] Error 2

CreateProcess failed? And "make (e=2): The system cannot find the file specified", what does this mean?

---------- Post updated at 08:39 AM ---------- Previous update was at 07:57 AM ----------

Now I got it! I'm not programming in Unix/Linux actually, I'm programming in Windows, using mingw. What I forgot is that rm in not a normal windows shell command. I had to install msys! When I installed it and added the bin folder to my path in windows, everything worked perfectly well!

Last edited by TriKri; 09-24-2009 at 03:22 AM..
  #4 (permalink)  
Old 09-25-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,972
I'm not sure you can put comments on the same line as commands etc. in makefiles.
  #5 (permalink)  
Old 09-25-2009
TriKri TriKri is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 4
Quote:
Originally Posted by Corona688 View Post
I'm not sure you can put comments on the same line as commands etc. in makefiles.
It should be possible.

Cited from Tutorial - Makefile:

some makefile statement
# a comment
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0