0

I am using the HTParse.c module for one of my C projects. However when compiling with

gcc -o project project.c -lpthread 

I receive the following compiler errors from within the header file:

  In file included from Gserve.c:12:0:
  /usr/local/include/w3c-libwww/HTParse.h:117:8: error: unknown type name ‘BOOL’
  extern BOOL HTURL_isAbsolute (const char * url);
         ^
  /usr/local/include/w3c-libwww/HTParse.h:192:8: error: unknown type    name ‘BOOL’
  extern BOOL HTCleanTelnetString (char * str);
         ^

I have read to include stdbool.h with C99 and that C90 does not support the boolean data type. Even after including this header, the errors persist. I have included these headers as follows:

 #include<stdbool.h>
 #include<w3c-libwww/HTParse.h>

Could something have gone wrong during the install of the library? I didn't see anything suspicious in the when making however I did notice some errors at the end of 'sudo make install'...

collect2: error: ld returned 1 exit status
Makefile:660: recipe for target 'libapp_2' failed
make[2]: *** [libapp_2] Error 1
make[2]: Leaving directory '/usr/local/src/w3c-libwww-       5.4.0/Library/Examples'
Makefile:174: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/w3c-libwww-5.4.0/Library'
Makefile:263: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1

I am using Ubuntu 15.10.

Do you guys have any Ideas for fixing this up?

Thanks Much!

2
  • "I have read to include stdbool.h with C99 and that C90 does not support the boolean data type" - Well, BOOL is from neither. It is usually a macro defined as int in a Windows header, or a compatibility header for compiling on non-Windows platforms. It seems you have neither. Commented Mar 28, 2016 at 4:35
  • Do you have other #include directives before those quoted? Can you compile a file that consists solely of #include <w3c-libwww/HTParse.h>? Commented Mar 28, 2016 at 5:11

1 Answer 1

1

The cause of this compiler error is that w3c-libwww defines BOOL in the header wwwsys.h, and you are not #includeing it or any of the other w3c-libwww headers that already #includes it. The library's API boilerplate is meant to be declared by:

#include <w3c-libwww/WWWLib.h>

before anything else. Look at the provided Examples either via the online documentation or in the Library/Examples folder in the package.

Correcting this error, however, will not enable you to compile and link a program with the library because you have not succeeded in building and installing the library.

The failure that you noticed from sudo make install means that you have not installed the library. But the error in question:

collect2: error: ld returned 1 exit status
Makefile:660: recipe for target 'libapp_2' failed   

is not an error of installing the library and its headers to their destination directories: it says that linkage of the library has failed.

make install, therefore, has attempted to make the library, as it will always do as long as library has not yet been built, and that make has failed because the library cannot be linked.

When I attempt myself to build the package, on Ubuntu 15.10, ./configure succeeds but make fails with:

gcc -g -O2 -Wall -o .libs/libapp_2 libapp_2.o  ../src/.libs/libwwwinit.so ../src/.libs/libwwwapp.so ../../Library/src/.libs/libwwwxml.so ../../modules/expat/xmlparse/.libs/libxmlparse.so ../../modules/expat/xmltok/.libs/libxmltok.so ../src/.libs/libwwwhtml.so ../src/.libs/libwwwtelnet.so ../src/.libs/libwwwnews.so ../src/.libs/libwwwhttp.so ../src/.libs/libwwwmime.so ../src/.libs/libwwwgopher.so ../src/.libs/libwwwftp.so ../src/.libs/libwwwdir.so ../src/.libs/libwwwcache.so ../src/.libs/libwwwstream.so ../src/.libs/libwwwfile.so ../src/.libs/libwwwmux.so ../src/.libs/libwwwtrans.so ../src/.libs/libwwwcore.so ../src/.libs/libwwwutils.so -lm ../../modules/md5/.libs/libmd5.so -ldl -Wl,--rpath -Wl,/home/imk/develop/w3c/lib
../src/.libs/libwwwfile.so: undefined reference to `HTDir_addElement'
../src/.libs/libwwwfile.so: undefined reference to `HTDir_free'
../src/.libs/libwwwfile.so: undefined reference to `HTDir_new'
collect2: error: ld returned 1 exit status
Makefile:660: recipe for target 'libapp_2' failed

No doubt that is what you saw too. You must regard a linkage failure of a library or executable you are trying to build as not merely "suspicious" but entirely fatal. Until you link it, you have no library.

Bottom line: This (14 yearold) package is broken on Ubuntu 15.10. There doesn't seem to be a well-known fix. I suggest you cut your losses.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a ton for your response! You definitely cleared up some of my general confusion with libraries in addition to saving me a few more hours of headache. A few questions if you have the time: Previously, I thought that the 'make' instruction was meant to compile the source of the library, why do you keep talking about 'make' causing linkage failure? After going back through my 'make' output, I did in fact notice some compiler warnings but none were actual errors. On a different note, would you have any recommendations for parsing a URL in C if this library is not an option for me?
@Lamar A makefile typically but not necessarily describes to make the complete recipe for constructing an executable from its source code, in terms of relationships of the form: if item A is out date with respect to the items B,C... from which it is made, then re-make it by doing X,Y,Z.... This recipe essentially involved compiling the source files to object files, then linking the object files with specified or default libraries to make the executable. If you don't understand the role of the linker, you are trying to run before you can walk: better research it.
@Lamar As for an alternative library I can't personally recommend one but this and this may help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.