简体   繁体   中英

C Static Library linking problems with NetBeans

Hello stackoverflow community. I have been trying to teach myself static and dynamic libraries in C. I am having an issue though. My linking does not appear to be working at all. I made a simple testing static library. Here is the code for the .c file:

#include <stdio.h>

void test(char * c)
{
    printf(c);
}

And the .h file:

#ifndef TEST_H
#define TEST_H

#ifdef  __cplusplus
extern "C" {
#endif




#ifdef  __cplusplus
}
#endif

extern void test(char * c);

#endif  /* TEST_H */

Here are the steps I take to produce the issue.

First, I build this static library project with NetBeans, which generates a .a library (I am using MinGW for compiling).

Then, I copy the .a file, as well as the library's .h file into a folder.

I then start a new C/C++ application project in NetBeans. I right click this project, and click properties. Then I go to the Build tab, and within that, the Linker tab. This is the part I am having troubles with. No matter what I link, NetBeans acts as if I have linked nothing. I have tried linking with "Additional Library Directories" and "Libraries". Neither have worked. I have even tried manually reparsing the file by right clicking the project, going to the code assistance menu option, and clicking Reparse Project.

Any help on figuring out what is wrong would be appreciated, thanks.

It appears that I forgot to link the library directory under build. To do this, I went to the project properties, the Build Tab, and the C Compiler tab, and then went to General, and added my library directory to "Include Directories and Headers".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM