Author Topic: Trying to link (and understand) static libraries.  (Read 6682 times)

19bernardo87

  • Guest
Trying to link (and understand) static libraries.
« on: October 03, 2008, 09:58:23 pm »
Hi, I'm fairly new to API's (and programming in general) and recently started on windows.

I'm attempting to use the OPENFILENAME struct, unfortunately I get an Undefined Reference error when I try to use the function GetOpenFileName: it seems that I need to link with comdlg32.lib.

I do so by specifying in "Build Options"-"Linker Settings" and Adding "..\..\..\..\..\watcom-1.3\lib386\nt\comdlg32.lib" to "Link Libraries."

However I now get this error:
..\..\..\..\..\watcom-1.3\lib386\nt\comdlg32.lib: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 3 seconds)
0 errors, 0 warnings

Also, for learning purposes, I'd like to know if I understand this.

The reason I get undefined reference is because the header file <windows.h> only contains the declaration of the function, its definition lies inside of comdlg32.lib, which is a set of source of files put together more or less.  Are these pre-compiled (already in object code, .o) and the linker just puts them together?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Trying to link (and understand) static libraries.
« Reply #1 on: October 04, 2008, 04:36:36 pm »
What compiler / OS / C::B version do you use (exactly)?

You don't mix compilers, right?! "collect2" seems to me like coming from GCC compilers suite but you try to use library components from Watcom?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

19bernardo87

  • Guest
Re: Trying to link (and understand) static libraries.
« Reply #2 on: October 05, 2008, 06:02:22 am »
What compiler / OS / C::B version do you use (exactly)?

You don't mix compilers, right?! "collect2" seems to me like coming from GCC compilers suite but you try to use library components from Watcom?!

You are correct, I wasn't aware static libraries were compiler specific.  Thanks a bunch. =D