Linker problems calling function getcwd() on unistd.h header
Posted: Mon Jul 07, 2014 4:33 am
Hello everybody,
I am not able to compile a simple project with only a main function with a call to the function:
getcwd();
Doing a CTRL+Click on the function call (and adding the typical include line on the top of the code) brings me to the expected header, but when compiled, an error appear (I think is a linker problem).
This is the code:
#include "predef.h"
#include <ucos.h>
#include <ip.h>
#include <stdio.h>
//#include <sys/unistd.h>
#include <unistd.h>
#include <buffers.h>
extern "C" {
void UserMain(void * pd);
}
void UserMain(void * pd) {
InitializeStack();
OSChangePrio(MAIN_PRIO);
iprintf("Application started\n");
char buf[2];
int s = 1;
getcwd ( buf, s); //There is the error
}
The compiler directories are OK (project settings), but I am not sure of have added the correct linker libraries. By now, I've added the libraries:
MOD5441X.a
NetBurner.a
FatFile.a
debugLibrary.a
Lua_Full
Which could be the librarie that link to <unistd.h>? (or to <sys/unistd.h>)
The error in NBEclipse is: "undefined reference to `getcwd'". Any help or comment will be very appreciated.
Regards,
Enric
I am not able to compile a simple project with only a main function with a call to the function:
getcwd();
Doing a CTRL+Click on the function call (and adding the typical include line on the top of the code) brings me to the expected header, but when compiled, an error appear (I think is a linker problem).
This is the code:
#include "predef.h"
#include <ucos.h>
#include <ip.h>
#include <stdio.h>
//#include <sys/unistd.h>
#include <unistd.h>
#include <buffers.h>
extern "C" {
void UserMain(void * pd);
}
void UserMain(void * pd) {
InitializeStack();
OSChangePrio(MAIN_PRIO);
iprintf("Application started\n");
char buf[2];
int s = 1;
getcwd ( buf, s); //There is the error
}
The compiler directories are OK (project settings), but I am not sure of have added the correct linker libraries. By now, I've added the libraries:
MOD5441X.a
NetBurner.a
FatFile.a
debugLibrary.a
Lua_Full
Which could be the librarie that link to <unistd.h>? (or to <sys/unistd.h>)
The error in NBEclipse is: "undefined reference to `getcwd'". Any help or comment will be very appreciated.
Regards,
Enric