Linking to a C library compiled as C++ -


I'm in Linker Paradise now I have a C Library that is compiled only in Visual C ++ (it's probably GCC If:

  1. I compile it as a C ++ code
  2. __cplusplus in all the announcements < Code> Extern "c" {}

The results result in being attached to it, by doing so I call a static library, say, Code> bsbs.lib

Now, I have tester < / Code> is a C ++ project, which calls repeated to bsbs.h . All are alright, as long as I do not attempt to link to bsbs.lib , where I am quite familiar:

  tester.obj : Error LNK2001: Unsolved exotic symbol _fofu  

and it always looks like fufu , which is tester ( barbar or something else).

Update: As requested, I've expanded on Point 2. Thanks a lot for the help guys!

  #ifndef _BSBS_H #define _BSBS_H / * Stop the C ++ program by associating these definitions. * / #ifdef __cplusplus extern "C" {#endif #include & lt; Stdio.h & gt; #include & lt; Setjmp.h & gt; ....... ....... #ifdef __cplusplus} #endif #endif/ * _BSBS_H * /  

This is the "main" header file, so to speak. All important functions are here but the other header files by the

no extern "c" {} are attached to the file bsbs.c .

Solution: OK, that's quite strange, but I removed the extern c bit from bsbs header file Given, it compiled a C ++ project (even if all files are .c and define __ cplusplus } and it worked! I see the symbol list The idea got after. Everyone attached to extern c (doh) was put in confusion, except and it was asking for an irresponsible symbol, so I It seemed that something was wrong.

If you declare them lib in extern c ( Which is unnecessary, if you are calling them from C ++), then they must be Exxton C. in their header.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -