Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: amit1947 on December 04, 2008, 08:23:22 pm

Title: C++ project can not call C static library functions
Post by: amit1947 on December 04, 2008, 08:23:22 pm
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!
Title: Re: C++ project can not call C static library functions
Post by: amit1947 on December 04, 2008, 08:36:39 pm
I forgot to mention that I'm using Code::Blocks in Ubuntu Linux.
Title: Re: C++ project can not call C static library functions
Post by: dje on December 04, 2008, 09:08:50 pm
Hi,

search the web for "extern c"

Dje
Title: Re: C++ project can not call C static library functions
Post by: amit1947 on December 04, 2008, 09:11:22 pm
Thanks for the help! That did it , I added

extern "C"{

function_prototypes();

}

to the C lib's header file and it works now.