News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Trying to link (and understand) static libraries.

Started by 19bernardo87, October 03, 2008, 09:58:23 PM

Previous topic - Next topic

19bernardo87

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?

MortenMacFly

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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

19bernardo87

Quote from: MortenMacFly 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?!

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