Pelles C forum

Pelles C => General discussions => Topic started by: player55 on February 02, 2013, 05:28:09 PM

Title: Compiling from the command line
Post by: player55 on February 02, 2013, 05:28:09 PM
Hi,

When I use Pelles C 32-bit and compile this code using cc main.c, it works.

Code: [Select]
#include <stdio.h>

int main(void) {
  printf("hello\n");
  return 0;
}

However, using the 64-bit version of Pelles C, also using cc main.c, I get a long list of errors like this:

Code: [Select]
...
POLINK: error: Unresolved external symbol '__imp__DeleteFileA@4'.
POLINK: fatal error: 34 unresolved external(s).
Title: Re: Compiling from the command line
Post by: Bitbeisser on February 02, 2013, 07:50:33 PM
Well, you get a linker error, not a compilation error.

Do you do this on the same machine or on two different ones?
What are the linker options passed to cc in either case?

Ralf
Title: Re: Compiling from the command line
Post by: TimoVJL on February 03, 2013, 09:52:25 AM
Try these.
Code: [Select]
cc -Tx86-coff hello.c -libpath:"%PellesCDir%\lib\win" -Fohello32.exe
Code: [Select]
cc -Tamd64-coff hello.c -libpath:"%PellesCDir%\lib\win64" -Fohello64.exe
EDIT: Fix path names with spaces and -Fo syntax.
Title: Re: Compiling from the command line
Post by: player55 on February 03, 2013, 09:25:41 PM
Well, you get a linker error, not a compilation error.

Do you do this on the same machine or on two different ones?
What are the linker options passed to cc in either case?

Ralf

Try these.
Code: [Select]
cc -Tx86-coff hello.c -libpath:%PellesCDir%\lib\win -Fo:hello32.exe
Code: [Select]
cc -Tamd64-coff hello.c -libpath:%PellesCDir%\lib\win64 -Fo:hello64.exe

Okay, I've figured it out. It seems that the default target is set to Tx86-coff for both 32-bit and 64-bit versions of POCC, but the library path is set to Lib\Win64\ by default in the 64-bit version, causing a conflict. By tweaking your lines timov, I reached to this:

The trailing backslash is important.

Code: [Select]
cc hello.c -libpath:"C:\Program Files\PellesC\Lib\Win\"
Code: [Select]
cc -Tamd64-coff hello.c