I have this program:
#include <windows.h>
int main(void){
MessageBoxA(0,"One","Two",0);
}
It's compiled like this:
C:\pellesc\bin\pocc.exe /IC:\pellesc\include /IC:\pellesc\include\win -Tamd64-coff -Ze /Ot program.c
producing program.obj, and linked like this:
C:\pellesc\bin\polink /LIBPATH:c:\pellesc\lib /LIBPATH:c:\pellesc\lib\win64 /OUT:program.exe @filelist
where filelist contains one line with program.obj
However it gives the error: POLINK: error: Unresolved external symbol '__imp_MessageBoxA'.
What do I have to do to link for Windows? This is for Pelles C 64-bits and runs on 64-bit Windows 7; does MessageBoxA still exist in this version?
Thanks.
MSDN gives that info in here (http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx).#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma comment(lib, "user32.lib")
int main(void){
return MessageBoxA(0,"One","Two",0);
}
Quote from: timovjl on January 31, 2014, 11:33:02 PM
MSDN gives that info in here (http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx).#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma comment(lib, "user32.lib")
int main(void){
return MessageBoxA(0,"One","Two",0);
}
Thanks, that worked. But, I have some questions about this:
o Why can't it just pick up the user32.lib file from the search path I've given it? (Actually why doesn't it just work? With other C compilers (gcc, lccwin, DMC) it doesn't need anything extra to link properly.)
o Will I need one of these for each library such as kernel32.lib etc? (I assume the pragmas are only needed in one module)
o Is there any #if expression I can use to detect that Pelles C is running? (In case I need to turn off the pragma when I want the same code to run on, say, lccwin, which doesn't like the syntax)
Quote from: sal55 on January 31, 2014, 11:56:39 PM
o Why can't it just pick up the user32.lib file from the search path I've given it? (Actually why doesn't it just work? With other C compilers (gcc, lccwin, DMC) it doesn't need anything extra to link properly.)
you can, insert it to filelist in own line
Quote
o Will I need one of these for each library such as kernel32.lib etc? (I assume the pragmas are only needed in one module)
only one of each and without pragmas too.
Quote
o Is there any #if expression I can use to detect that Pelles C is running? (In case I need to turn off the pragma when I want the same code to run on, say, lccwin, which doesn't like the syntax)
__POCC_ as help says ;)
BTW: have you checked povars32.bat from Pelles\bin ?
Quote from: sal55 on January 31, 2014, 11:56:39 PM
o Why can't it just pick up the user32.lib file from the search path I've given it? (Actually why doesn't it just work? With other C compilers (gcc, lccwin, DMC) it doesn't need anything extra to link properly.)
Some of these compilers resolve dependencies on their own or have more libraries added by default.
Quote from: timovjl on February 01, 2014, 01:58:52 AM
you can, insert it to filelist in own line
OK, that worked, thanks. But I'm still puzzled why it couldn't find it in the LIB\WIN64 path I gave it.
Quote
__POCC_ as help says ;)
Yes, but I have to find it first! (And even armed with this information, I can't find any trace of it, not in help0009.chm)
QuoteBTW: have you checked povars32.bat from Pelles\bin ?
I've tried povars64.bat, but I prefer to do it without having to run this (I can't even remember how to auto-run a batch file!).
Quote from: sal55 on February 01, 2014, 12:23:39 PMQuote
__POCC_ as help says ;)
Yes, but I have to find it first! (And even armed with this information, I can't find any trace of it, not in help0009.chm)
Commanline tools -> POCC compiler -> Predefined preprocessor symbols ;)
Quote from: sal55 on February 01, 2014, 12:23:39 PM
QuoteBTW: have you checked povars32.bat from Pelles\bin ?
I've tried povars64.bat, but I prefer to do it without having to run this (I can't even remember how to auto-run a batch file!).
Create shortcut with target
%COMSPEC% /k c:\PellesC\bin\povars64.bat for console ;)
^^ Thanks i missed that :)