How do I get C-code going in a visual C++ .NET library

H

Hans

I have some ancient routines I want to use in a Visual
C++ .NET class library but I cannot get it compiled.

I get link errors on goniometrical functions:

Calculator error LNK2001: unresolved external
symbol "double __cdecl cos(double)" (?cos@@$$J0YANN@Z)
Calculator error LNK2001: unresolved external
symbol "double __cdecl sin(double)" (?sin@@$$J0YANN@Z)

as well as on

Calculator error LNK2001: unresolved external symbol "int
__cdecl sprintf(char *,char const *,...)" (?
sprintf@@$$J0YAHPADPBDZZ)
Calculator error LNK2001: unresolved external symbol "int
__cdecl sscanf(char const *,char const *,...)" (?
sscanf@@$$J0YAHPBD0ZZ)

Can anybody help me out here???

Tanx,
Hans.
 
G

Guest

I have some ancient routines I want to use in a Visual
C++ .NET class library but I cannot get it compiled.

I get link errors on goniometrical functions:

Calculator error LNK2001: unresolved external
symbol "double __cdecl cos(double)" (?cos@@$$J0YANN@Z)
Calculator error LNK2001: unresolved external
symbol "double __cdecl sin(double)" (?sin@@$$J0YANN@Z)
....

I discovered that you must dynamically link to the mfc libraries.
Static linking to these libraries also generates errors like this.

Another potential cause is that you use different projects in your sollution
and one is using cdecl and the other one standard calling convention.
Every project must have the same settings. for example both use
multithreaded libraries.

Also be aware of mfc dll's. (mfc70.dll, msvcp70.dll, msvcr70.dll) and the
debug counter parts.
Not every user has these dll's installed default. .NET generated
managed/unmanaged mixed code needs these in the same location of your dll.
Failure to do so, will generated very hard to trace exceptions. Pure .NET
managed code does not have these problems.

In the end you will love this .NET thing, but in the transition you probably
lose half your hair beause of mysterious bugs and errors. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top