[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Handle-info] compile c client library



Dear Laurence,

Thanks very much. Setting LDFLAGS outside the Makefile does not solve
the problem either. Below I am summarising the problem again:

I unzipped the c client library to /home/peng/hcc5. Then in the
directory I ran ./configure -prefix=$PWD , make and make install, one
by one as advised in the install.txt.

After setting the environment variable LDFLAGS as /home/peng/hcc5/lib
, I tried to compile the example code hscreate.c in hcc5/test by
entering the directory and executing "make hscreate". But I got the
following error message:

/bin/sh ../libtool --mode=link gcc  -g -O2 -lhdl  -o hscreate  hscreate.o
gcc -g -O2 -o hscreate hscreate.o  /usr/local/lib/libhdl -Wl,--rpath
-Wl,/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib
hscreate.o: In function `main':
/home/peng/hcc5/test/hscreate.c:85: undefined reference to `HDLCreate'
collect2: ld returned 1 exit status
make: *** [hscreate] Error 1

Best wishes,

Peng

On 20 August 2012 12:48, Finston, Laurence <laurence.finston@gwdg.de> wrote:
> Please leave the handle-info mailing list on the "cc".
>
>> I found LDFLAGS in the Makefile which was blank and set it as
>> "-L/home/peng/hcc5/lib" where the libhdl file can be found. But it
>> does not seem to solve the problem.
>
> I don't quite understand this.   The path to the library must be set with the -L option  when you link the programs
> in `hcc5/test'.  I don't recommend changing the Makefile in that directory, it was generated using Automake and isn't intended to be modified by hand.   Setting LDFLAGS in the environment should work.  If it doesn't, please post the output from make to this list and perhaps someone will be able to see what the problem is.
>
> Laurence
> ________________________________________
> From: Peng Du [eddy.pdu@gmail.com]
> Sent: Monday, August 20, 2012 12:42 PM
> To: Finston, Laurence
> Subject: Re: [Handle-info] compile c client library
>
> Thanks Laurence,
>
> I found LDFLAGS in the Makefile which was blank and set it as
> "-L/home/peng/hcc5/lib" where the libhdl file can be found. But it
> does not seem to solve the problem.
>
> Best wishes,
>
> Peng
>
> On 20 August 2012 07:54, Finston, Laurence <laurence.finston@gwdg.de> wrote:
>>> And last item, i.e. -lhdl, does the linking. So I don't quite
>>> understand why it is not working.
>>
>> The linker requires the path to the library, which you can pass to it  using the -L option, the LDFLAGS environment variable or setting the default path (in /etc/ld.so.conf or whatever your system uses).
>>
>> Laurence
>>
>> ________________________________________
>> From: Peng Du [eddy.pdu@gmail.com]
>> Sent: Sunday, August 19, 2012 6:14 PM
>> To: Finston, Laurence
>> Subject: Re: [Handle-info] compile c client library
>>
>> Hello Laurence,
>>
>> I had a look at the directory and libhdl is located under hcc5/lib . I
>> think the Makefile in hcc5/test already include the linking to the
>> library as the following can been seen from the command line when I
>> type "make hscreate".
>>
>> /bin/bash ../libtool --mode=link gcc  -g -O2 -lhdl  -o hsaddvals  hsaddvals.o
>> gcc -g -O2 -o hsaddvals hsaddvals.o  -lhdl
>>
>> And last item, i.e. -lhdl, does the linking. So I don't quite
>> understand why it is not working.
>>
>> Thanks very much.
>>
>> Regards,
>>
>> Peng
>>
>>
>> On 17 August 2012 15:37, Finston, Laurence <laurence.finston@gwdg.de> wrote:
>>> The client library itself, i.e., `libhdl', which is built by the targets in the top-level Makefile.  The general idea is, if one wants to write an application that accesses a Handle Server, one writes a program in C or C++, includes the header files from the handle library (presumably in an include/ subdirectory) for the declarations (needed at compile-time), and links to the library using the -l and -L flags to the linker at link-time in order to access the definitions.  At run-time, the run-time system needs to be able to find the library in order to execute the functions, therefore LD_LIBRARY_PATH must include the path to the library.
>>>
>>> I have now downloaded the package and see that it does indeed use Autoconf and Automake to generate the configure script and Makefiles.
>>>
>>> I assume that the programs in the test/ subdirectory link are meant to link to libhdl, a cursory look at the Makefile.am in that directory seems to confirm this, and it's what I would expect with most packages.
>>>
>>> So, when you build the programs in test/, you need to link to the hdl library, either with the appropriate flags passed to the linker, or via the corresponding environment variables.  Regarding the default path to libraries, there's also the possibility of setting it using /etc/ld.so.conf or whatever your system uses.  I just mention this for the sake of completeness;  I wouldn't bother with this at the moment.
>>>
>>> Laurence
>>> ________________________________________
>>> From: Peng Du [eddy.pdu@gmail.com]
>>> Sent: Friday, August 17, 2012 4:10 PM
>>> To: Finston, Laurence
>>> Cc: handle-info@cnri.reston.va.us
>>> Subject: Re: [Handle-info] compile c client library
>>>
>>> Hi Laurence,
>>>
>>> Many thanks for the detailed answers and suggestions.
>>>
>>> However I do not quite follow why I need to link any library in the
>>> first place? And what library do I need to link? Since it is not
>>> mentioned in the source code.
>>>
>>> Regards,
>>>
>>> Peng
>>>
>>> On 17 August 2012 14:39, Finston, Laurence <laurence.finston@gwdg.de> wrote:
>>>> LD_LIBRARY_PATH is used at run-time, while LDFLAGS is used at link-time.  In other words, LD_LIBRARY_PATH won't do you any good until you've successfully linked your program.  You'll also need to set LIBS for linking, as below.  If you set them before calling configure, rather than setting them as part of the call to configure, be sure they've been exported.  Sorry if that's obvious, but I thought it best to mention it, just in case.
>>>>
>>>> If this still doesn't work, you could just try linking by hand.  You should see the command that's used when you run `make' and you could just run it from the shell, adding the appropriate flags with their arguments.  If the makefile was generated using Automake, `make -n <target>' will show you what would be run for <target> without actually running it.
>>>>
>>>> If this doesn't work, I could try installing the library myself next week.  I won't be able to do it sooner.  Probably someone else will be able to help you in the meantime, though.
>>>>
>>>> However, I think the C library may be somewhat out-of-date compared to the Java library.  It might actually make more sense to use JNI to call the functions from the Java API from a C or C++ program rather than using the C API, but I don't know this for sure.
>>>>
>>>> Laurence
>>>>
>>>> ________________________________________
>>>> From: Peng Du [eddy.pdu@gmail.com]
>>>> Sent: Friday, August 17, 2012 3:23 PM
>>>> To: Finston, Laurence
>>>> Cc: handle-info@cnri.reston.va.us
>>>> Subject: Re: [Handle-info] compile c client library
>>>>
>>>> Dear Laurence,
>>>>
>>>> Thanks very much for your reply!
>>>>
>>>> I did try to set environment variables, as required by install.txt.
>>>> Specifically, I used "./configure --prefix=$PWD" and accordingly I set
>>>> LD_LIBRARY_PATH=$PWD/lib/perl/5.10/auto/hdllib/ . But the problem
>>>> still remains.
>>>>
>>>> Best wishes,
>>>>
>>>> Peng
>>>>
>>>> On 17 August 2012 14:06, Finston, Laurence <laurence.finston@gwdg.de> wrote:
>>>>> Hello,
>>>>>
>>>>>> I have installed (configure - make - make install) the c version
>>>>>> client libraries. But when I tried to make the programs in hcc5/test,
>>>>>> it keeps reporting "undefined reference to HDLCreate" or "undefined
>>>>>> reference to HDLDelete", depending on the specific program to build.
>>>>>
>>>>>> Would anyone kindly advise me on this? Thanks very much!
>>>>>
>>>>> This is just general information, since it's been a couple of years since I installed the C client library (with some help from one or more people on this  mailing list).  I was, however, encouraged to use the Java library instead at the time.
>>>>>
>>>>> You have to make sure that the library is found when linking.  You can do this with the -l and -L flags.
>>>>> -l is for the name of the library, without the prepended `lib', e.g., `-lpcat' for the library `libpcap'.
>>>>> -L is for the search path for libraries.  So, if you've installed a library in a non-standard location, you can add directories (separated by the `:' character) to the search path with this linker option.
>>>>>
>>>>> Alternatively, you could set the appropriate environment variables.
>>>>>
>>>>> If you type `configure --help', you may get something like this (if the configure script was generated by Autoconf):
>>>>>
>>>>> [...]
>>>>> Some influential environment variables:
>>>>>   CXX         C++ compiler command
>>>>>   CXXFLAGS    C++ compiler flags
>>>>>   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
>>>>>               nonstandard directory <lib dir>
>>>>>   LIBS        libraries to pass to the linker, e.g. -l<library>
>>>>>   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
>>>>>               you have headers in a nonstandard directory <include dir>
>>>>>   CC          C compiler command
>>>>>   CFLAGS      C compiler flags
>>>>> [...]
>>>>>
>>>>> On my (Linux) system, the default search path for libraries is set in `/etc/ld.so.conf'.
>>>>>
>>>>> I hope this helps.
>>>>>
>>>>> Laurence Finston
>>>>> ________________________________________
>>>>> From: handle-info-admin@cnri.reston.va.us [handle-info-admin@cnri.reston.va.us] on behalf of Peng Du [eddy.pdu@gmail.com]
>>>>> Sent: Friday, August 17, 2012 2:20 PM
>>>>> To: handle-info@cnri.reston.va.us
>>>>> Subject: [Handle-info] compile c client library
>>>>>
>>>>> Hello there,
>>>>>
>>>>> I have installed (configure - make - make install) the c version
>>>>> client libraries. But when I tried to make the programs in hcc5/test,
>>>>> it keeps reporting "undefined reference to HDLCreate" or "undefined
>>>>> reference to HDLDelete", depending on the specific program to build.
>>>>>
>>>>> Would anyone kindly advise me on this? Thanks very much!
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Peng
>>>>>
>>>>> _______________________________________________
>>>>> Handle-Info mailing list
>>>>> Handle-Info@cnri.reston.va.us
>>>>> http://www.handle.net/mailman/listinfo/handle-info

_______________________________________________
Handle-Info mailing list
Handle-Info@cnri.reston.va.us
http://www.handle.net/mailman/listinfo/handle-info