Linker problems calling function getcwd() on unistd.h header

Discussion to talk about software related topics only.
Post Reply
geolab
Posts: 3
Joined: Mon Jul 07, 2014 4:14 am

Linker problems calling function getcwd() on unistd.h header

Post by geolab »

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
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Linker problems calling function getcwd() on unistd.h he

Post by dciliske »

Umm... I'm not sure getcwd makes sense to even use in an embedded environment. Can you articulate what you are attempting to do?

Also, when I say that I'm not sure it even makes sense, that's because you're effectively running the program you're writing as the OS, not something launched from a shell.

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
sulliwk06
Posts: 118
Joined: Tue Sep 17, 2013 7:14 am

Re: Linker problems calling function getcwd() on unistd.h he

Post by sulliwk06 »

If you're using the EFFS FAT file system, I believe there is an f_getcwd. Otherwise I'm not sure what you expect getcwd to return.
geolab
Posts: 3
Joined: Mon Jul 07, 2014 4:14 am

Re: Linker problems calling function getcwd() on unistd.h he

Post by geolab »

Thanks to dciliske and sulliwk06. Now, I don't use anymore the getcwd() function.
Post Reply