Archived

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

flukus

Need help with libs!!!

Recommended Posts

OK. I know theres probably a very simple step that I''m missing but I don''t have a clue what it is. I''m getting this link error: chap2.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7 I''ve tried putting the ddraw.lib and ddraw.h in the directory and inluded them through Project -> add to project. I''ve got #include <ddraw.h> at the top of the page. I''ve tried the rebuild all option that worked last time I had a similar area. So who here wants to make me look stupid and point out what I did wrong?

Share this post


Link to post
Share on other sites
im confused, did u include ddraw.lib thru project->add to project, cause that seems wrong, ur supposed to go to project-> settings->link and then include the lib

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-

Share this post


Link to post
Share on other sites
I''ve had FMod work fine by including the lib file using "add to project".

Anyway, I tried adding it through settings-> link and I still get the same error message!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have a small question regarding linking libs.

I have this A.lib compiled using C calling conventions...
I dont have access to the code, only the lib file.

In my application, I use a B.lib that is compiled using C++
(a different lib which I have code access to)
That B.lib is using functions from the A.lib and I have included the lib file in the lib list in the project settings,

BUT IT STILL COMPLAINS ABOUT UNRESOLVED EXTERNALS.

B.lib is compiler using C++ notation. (.cpp files and such no /Tp or /Tc compiler options anywhere.)

Similar problems with linking was resolved by adding extern "C" to the problem libs. But in this case, I cannot recompile the A.lib since I dont have access to the code.

Is my problem due to the fact that my B.lib is compiled using C++ and the A.lib is compiled using C?

In such case, is there any way that I can force the linker to accept A.libs C notation so that the functions doesnt get unresolved?

A.lib have all the functions in it, I just cannot get the linker to understand them.

Any ideas?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have a small question regarding linking libs.

I have this A.lib compiled using C calling conventions...
I dont have access to the code, only the lib file.

In my application, I use a B.lib that is compiled using C++
(a different lib to which I coded myself)
That B.lib is using functions from the A.lib and I have included the lib files in the lib list in the project settings,

BUT IT STILL COMPLAINS ABOUT UNRESOLVED EXTERNALS.

B.lib is compiled using C++ notation. (.cpp files and such no /Tp or /Tc compiler options anywhere.)

Similar problems with linking was resolved by adding extern "C" to the problem libs. But in this case, I cannot recompile the A.lib since I dont have access to the code.

Is my problem due to the fact that my B.lib is compiled using C++ and the A.lib is compiled using C?

In such case, is there any way that I can force the linker to accept A.libs C notation so that the functions doesnt get unresolved?

A.lib have all the functions in it, I just cannot get the linker to understand them.

Any ideas?

Share this post


Link to post
Share on other sites
Make sure the function definitions for the plain C functions are wrapped in extern "C" when used in a .cpp file. Like this...

// In B.cpp
extern "C"
{
#include "A.h"
}


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Changed around alittle.

In my B.lib I put all includes in a B.h and added

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <malloc.h>
#include "B.h"
#include "B_extra.h"
#include "A.h"
#include "something.h"

#ifdef __cplusplus
}
#endif

... and now Im still getting unresolved externals from A.lib.
The strange part is that now its some other functions in A.lib that is unresolved.

Im quite sure about that the compiler mismatch C++ and C linkage somehow. Because all my other problems due to this was resolved by simply adding extern "C" in the problem libs.
However, with A.lib this is not an option.

/Desperate.



Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Flukus:

Try linking with dxguid.lib too, i.e. Project->Settings->Link

Or "#define INITGUID" before including ddraw.h

That should do it.

- Calvin

Share this post


Link to post
Share on other sites
Note that INITGUID should only be done from one cpp file. It will make errors if you do it in more than one, or do it in a header that is included in more than one.

Anyway, to the thread-stealing anonymous poster...

Extern "C" tells the C++ compiler to use C linkage for functions declared inside that block. If you really understand that you won''t have any problems.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites