CommandLine.cpp:189: error: `strdup' undeclared

Hi Guys

I'm trying to port and build LLVM to the Interix environment. I've succeded until the Interix version of gcc program executes:

Before the patch:

gmake[1]: Entering directory `/usr/local/src/llvm/lib/Support'
gmake[1]: Leaving directory `/usr/local/src/llvm/lib/Support'
gmake[1]: Entering directory `/usr/local/src/llvm/lib/Support'
Compiling CommandLine.cpp
CommandLine.cpp: In function `void ParseCStringVector(std::vector<char*,
   std::allocator<char*> >&, const char*)':
CommandLine.cpp:189: error: `strdup' undeclared (first use this function)
CommandLine.cpp:189: error: (Each undeclared identifier is reported only once
   for each function it appears in.)
CommandLine.cpp: In function `void llvm::cl::ParseEnvironmentOptions(const
   char*, const char*, const char*)':
CommandLine.cpp:230: error: `strdup' undeclared (first use this function)
gmake[1]: *** [/usr/local/src/llvm/lib/Support/Debug/CommandLine.lo] Error 1
gmake[1]: Leaving directory `/usr/local/src/llvm/lib/Support'
gmake: *** [all] Error 1

After the patch:

gmake[1]: Entering directory `/usr/local/src/llvm/lib/Support'
gmake[1]: Leaving directory `/usr/local/src/llvm/lib/Support'
gmake[1]: Entering directory `/usr/local/src/llvm/lib/Support'
Compiling CommandLine.cpp
CommandLine.cpp: In function `void ParseCStringVector(std::vector<char*,
   std::allocator<char*> >&, const char*)':
CommandLine.cpp:190: error: `strdup' undeclared (first use this function)
CommandLine.cpp:190: error: (Each undeclared identifier is reported only once
   for each function it appears in.)
CommandLine.cpp: In function `void llvm::cl::ParseEnvironmentOptions(const
   char*, const char*, const char*)':
CommandLine.cpp:231: error: `strdup' undeclared (first use this function)
gmake[1]: *** [/usr/local/src/llvm/lib/Support/Debug/CommandLine.lo] Error 1
gmake[1]: Leaving directory `/usr/local/src/llvm/lib/Support'
gmake: *** [all] Error 1

It seems that the declaration of strdup is still missing.

I've ran a test run in the Support directory and the outcome was this:

%cd where-you-want-llvm-to-live
%cd cd lib/Support/
%gcc -c CommandLine.cpp -o CommandLine.o 2>&1 | tee -a Make.log
...
CommandLine.cpp:178: error: `input' undeclared (first use this function)
CommandLine.cpp:190: error: `output' undeclared (first use this function)
CommandLine.cpp:190: error: `strdup' undeclared (first use this function)
...
%

Line 178 and and the 1st line 190 (input and output) is not present when building via the supplied make file. I suspect it is a include path that's not correct. Where do your <string> and <cstring> live in the view of GCC and the make file?

I have a <cstring> located in '/opt/gcc.3.3/include/c++/3.3' and <string> located more places including in the listed directory.

My version of LLVM is 1.2 and gcc 3.3.

/Henrik

That should work fine. I'm not familiar at all with internix, but it
appears to have a buggy header or something. From what I understand,
internix is a posix layer for windows. Have you tried compiling under
cygwin? If you grab the latest CVS sources, they should work fine with
cygwin, and will probably work better with windows in general than LLVM
1.2.

Again, I'm sorry that I don't know more about this and why <cstring>
apparently doesn't have strdup, it seems really odd. If <cstring> doesn't
work, you could try <string.h> explicitly, but it would be much better to
use cygwin if you can.

-Chris