GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Nov 20, 2014 10:58 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Problems with pkg-config
PostPosted: Thu Jun 26, 2008 8:26 pm 
Offline
Familiar Face

Joined: Wed Mar 19, 2008 3:23 pm
Posts: 19
Hello,

I followed a tutorial for creating a simple gtk application in windows using MinGW. The c-code should be correct, it's the linking that's troubling:

Code:
CC=gcc
CFLAGS=`pkg-config --cflags --libs gtk+-2.0`
CFLAGS+=-mwindows
SRC=hello.c
OBJ=$(SRC:.c=.o)
OUT=hello.exe

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

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

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


The compile complains and says

Code:
mingw32-make -k
rm hello.o #Remove .o
process_begin: CreateProcess(NULL, rm hello.o #Remove .o, ...) failed.
make (e=2): Det går inte att hitta filen.^M
mingw32-make: *** [all] Error 2


A little is in Swedish, that part says

Code:
make (e=2): The system cannot find the file specified.^M


I don't know what the ^M does there. I can't understand what it means, what file does it mean? I have MinGW installed directly under C:\MinGW, the path to mingw32-make.exe is set, and PKG_CONFIG_PATH is set as well.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 8:40 pm 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 286
Location: Fortress of solitude
Normally I use Scons, but when I was in make times, I used to just type write this into a file name makefile:
[code=]
all:
gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags --libs gtk+-2.0 `
[/code]
See the tutorial. No need to create a fancy makefile :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 8:46 pm 
Offline
Familiar Face

Joined: Thu Jun 26, 2008 8:42 pm
Posts: 5
Hi TriKri,
It appears that mingw32-make can't find the "rm" application. Since you're apparently not using a linux shell or a clone (like MSYS or Cygwin), your shell (which should be cmd) can't find rm as it doesn't exist in Windows. You can try replacing it with "del" and if that doesn't work, just put a # in front of the whole line and delete the .o files manually.

Cheers,
mod


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 8:51 pm 
Offline
Familiar Face

Joined: Wed Mar 19, 2008 3:23 pm
Posts: 19
Hello! Hello World!

Thank you! Finally it works. Lucky there's someone who knows shell commands. Myself, I am totally lost when it comes to that.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 8:54 pm 
Offline
Familiar Face

Joined: Thu Jun 26, 2008 8:42 pm
Posts: 5
Sure, no problem. I'd suggest moving to MSYS as your primary shell, though, because many Makefiles don't have any Windows-specific translations.

_________________
http://modulatum.wordpress.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 9:10 pm 
Offline
Familiar Face

Joined: Wed Mar 19, 2008 3:23 pm
Posts: 19
It's funny. Just because I got it to work once, it doesn't mean that the exact same code can be compiled twice.

I changed rm to del and compiled successfully. Then I changed it back to rm to notice the difference, and it failed. Now, when I have changed back to del again, it's not working!

Here's what it says:

Code:
Compilation started at Thu Jun 26 23:03:20

mingw32-make -k
gcc  hello.c  `pkg-config --cflags --libs gtk+-2.0`  -mwindows  -c #Create .o
cc1.exe: error: unrecognized command line option "-fcflags"
cc1.exe: error: unrecognized command line option "-flibs"
gcc: `pkg-config: No such file or directory
gcc: gtk+-2.0`: No such file or directory
gcc: #Create: No such file or directory
gcc: .o: No such file or directory
mingw32-make: *** [hello.o] Error 1
mingw32-make: Target `all' not remade because of errors.

Compilation exited abnormally with code 2 at Thu Jun 26 23:03:20


I have even re-loaded the original file and tried with that (after changing to del). How can it come it doesn't say the same thing as before, even though I change back to rm (as in the first post)? It doesn't matter if I use rm or del, it still outputs the same error. At least I have one Hello World executable.


Last edited by TriKri on Thu Jun 26, 2008 9:30 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 9:18 pm 
Offline
Familiar Face

Joined: Thu Jun 26, 2008 8:42 pm
Posts: 5
Edit: Never mind, when I try to compile using the command prompt, I get the same errors you get. In MSYS, everything works fine, so I'd suggest trying your luck there.

_________________
http://modulatum.wordpress.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 9:33 pm 
Offline
GTK+ Geek

Joined: Wed May 28, 2008 5:49 pm
Posts: 66
pkg-config doesn't work with the normal shell. Install MSYS, or run pkg-config manually, and manually add the paths it gives you to the makefile (not recommended, as it's somewhat time consuming).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 9:38 pm 
Offline
Familiar Face

Joined: Wed Mar 19, 2008 3:23 pm
Posts: 19
I run Emacs, and compile from there using the minibuffer. I guess it just picks cmd.exe by default, and I have to change it somehow. I just changed the ComSpec variable in Environment Variables to C:\msys\1.0\msys.bat, restarted my computer, changed back from del to rm in my Makefile. But it didn't work, that's why I think it's Emacs who want's to use cmd.exe and it's that I have to change.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 9:39 pm 
Offline
Familiar Face

Joined: Thu Jun 26, 2008 8:42 pm
Posts: 5
There's nothing stopping you from coding in emacs and having msys open to type in the occasional "make." :D

_________________
http://modulatum.wordpress.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 10:05 pm 
Offline
Familiar Face

Joined: Wed Mar 19, 2008 3:23 pm
Posts: 19
Problem solved. I added C:\msys\1.0\bin to PATH! :D I weren't able to find a shell-file-name (Emacs variable :p) that made me compile without any error, I tried both rxvt.exe and sh.exe, but both of them differed in look and function from MSYS.bat. Thank you for pointing out the fact that I should really use MSYS and not cmd.exe!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 10:10 pm 
Offline
Familiar Face

Joined: Thu Jun 26, 2008 8:42 pm
Posts: 5
Awesome! Glad you're up and running.

_________________
http://modulatum.wordpress.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group