• Advertisement

Archived

This topic is now archived and is closed to further replies.

problem with the compiler

This topic is 5133 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi!, i''m tired of repeating the same code everytime want to make a DX9 program, so i decided to make some kind of library such as gdiplus or mfc (BTW i''m too far from that, hehe...) so i put my files into a custom folder but at compile time, i get unresolved externals. i noticed of course that other libraries (again, such as gdi+ and DirectX) have a .lib file so i suposse i''ve got to make that file for my library too, but the question is how?? what do i have to code?? thanks in advance PD: i''m using visual studio .net 2002

Share this post


Link to post
Share on other sites
Advertisement
Unresolved externals in this case probably means that you failed to link your code with the lib files. Solve the problem you have rather than sidestepping it.

As for creating static libraries, simply change your project type to static library. You don''t need an entry point (main); all your code gets compiled and linked into a static object file (.lib), which you link with your application code at a later time.

Share this post


Link to post
Share on other sites
i already know that it was because i didn't link the library, that's why i was asking how to make one, AND IT WORKED!!!

thanks!!

but for the sake of my knowledge please could you tell me why do i need to make a lib?? if i'm already including the header files...???

[edited by - firecast on February 6, 2004 1:31:47 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by firecast
but for the sake of my knowledge please could you tell me why do i need to make a lib?
When you compile a piece of code, the compiler needs to be able to reduce all functions and data structures to basic types - resolve all declarations and prototypes - which is why we "include" files into other files; the preprocessor literally copies the contents of the included file into the including file, and this completed file is called a translation unit. The result of compiling a translation unit is an object file. This contains relocatable code (more on that in a second), but it can not necessarily be executed on its own (it can if there are no unresolved references).

Unresolved references indicate that relocatable code from other translation units/object files is invoked within the current object file, requiring a link. What the linker does is take several object files and rearrange their object code into a single executable file, resolving all references into hard offsets into the file (ie, saying that "function X can be found at byte Y" where Y is a fixed, as opposed to relative, number). Dynamically linked code is orthogonal to this concept and a separate discussion.

Because you were building object files that relied on code in other object files (static libraries are like archives of object files), those references needed to be resolved in order for a new static lib/archive to be built.

Hope that helped.

Share this post


Link to post
Share on other sites
yeah... i guess...

so like i''m using classes that aren''t inside my project, the definition of that functions aren''t being turned into .obj files so i need a lib which alreay has the implementation of those functions right??

well, it worked anyway so thanks a lot

Share this post


Link to post
Share on other sites

  • Advertisement