NO

Author Topic: Compiling from the command line  (Read 6645 times)

player55

  • Guest
Compiling from the command line
« 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).
« Last Edit: February 02, 2013, 05:34:25 pm by player55 »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 771
Re: Compiling from the command line
« Reply #1 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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1950
Re: Compiling from the command line
« Reply #2 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.
« Last Edit: February 04, 2013, 01:22:14 pm by timovjl »
May the source be with you

player55

  • Guest
Re: Compiling from the command line
« Reply #3 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
« Last Edit: February 03, 2013, 09:27:27 pm by player55 »