user886045
user886045

Reputation:

Compiling C with non standard header

I have my main C file:

#if defined(WIN32)
#include <windows.h>
#include <stddef.h>
#endif
#if defined(LINUX)
#include <curses.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(WIN32)
#include <conio.h>
#endif
#include <ctype.h>
#include <a429usbnt.h>

#if defined(WIN32)
#include "genlib.h"
#endif

void main()
{
    _open_xpc(1);
}

When I try to compile using this command

gcc -I. -L. test.c -o test 

I get the following error: undefined reference to '_open_xpc'.

However if I change the call to the _open_xpc function and instead just

printf("%d", XPC_ERROR_ACTIONCODE);

the program compiles fine and the correct value assigned to the definition of XPC_ERROR_ACTIONCODE is printed out, so the compiler is linking a429usbnt.h but will only recognize defined variables and not the functions.

Upvotes: 0

Views: 196

Answers (1)

user886045
user886045

Reputation:

If you are trying to link against a .lib file with gcc, it seems you need to define a directory with -L and an actual file with -l

Upvotes: 1

Related Questions