how i can link c library from c++ class
-
i have C library which i need to invoke from c++ class but when i tried to invoke the functions of the c library i am getting linker error of particlar function Can anybody help thanx
-
i have C library which i need to invoke from c++ class but when i tried to invoke the functions of the c library i am getting linker error of particlar function Can anybody help thanx
When you declare the function, wrap it in an extern "C":
extern "C" { extern void the_c_function() ; }
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 1.1.5 [^]: A free RSS reader with support for Code Project.
-
When you declare the function, wrap it in an extern "C":
extern "C" { extern void the_c_function() ; }
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 1.1.5 [^]: A free RSS reader with support for Code Project.
Thanx for reply This should be in library or in my class if so i don't have c library source code then how can modify it thax..
-
Thanx for reply This should be in library or in my class if so i don't have c library source code then how can modify it thax..
Wrap the header file:
extern "C" { #include "api.h" }
Or just duplicate the declarations you want. If you're writing a C library, it's good form to put the extern "C" *inside* the header file but not every one does it.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 1.1.5 [^]: A free RSS reader with support for Code Project.