User forums > Using Code::Blocks
C++ project can not call C static library functions
(1/1)
amit1947:
Hi everyone, I'm just getting started with Code::Blocks but I have some issues. I created a static library with C (.a extension) and I want to call these functions within another C++ project. When I try to build the C++ project I get an error in the Build Log : "undefined reference to 'HwOpen()' ". HwOpen() is a function in the static library.
I went into the C++ Project's build options and selected the correct lib.a file in the "Linker Settings" tab.
I know this process worked when I called the static library functions from a C project, but I think I need to do something else for the C++ project.
Thanks for any help!
amit1947:
I forgot to mention that I'm using Code::Blocks in Ubuntu Linux.
dje:
Hi,
search the web for "extern c"
Dje
amit1947:
Thanks for the help! That did it , I added
extern "C"{
function_prototypes();
}
to the C lib's header file and it works now.
Navigation
[0] Message Index
Go to full version