Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors - undefined reference #1

Closed
robsyme opened this issue Apr 5, 2012 · 10 comments
Closed

Compilation errors - undefined reference #1

robsyme opened this issue Apr 5, 2012 · 10 comments

Comments

@robsyme
Copy link

robsyme commented Apr 5, 2012

Hi,

I'm trying to compile tabixpp on ubuntu , but am getting a lot of "undefined reference to xxxxx" errors (https://gist.github.com/2309326)

Am I missing a step? Is this a known issue?

rob-> make
make[1]: Entering directory `/home/rob/src/github/freebayes/vcflib/tabixpp'
gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE  bgzf.c -o bgzf.o
bgzf.c: In function ‘bgzf_close’:
bgzf.c:630:8: warning: variable ‘count’ set but not used [-Wunused-but-set-variable]
gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE  kstring.c -o kstring.o
gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE  knetfile.c -o knetfile.o
knetfile.c: In function ‘khttp_connect_file’:
knetfile.c:418:2: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
knetfile.c: In function ‘kftp_send_cmd’:
knetfile.c:239:2: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE  index.c -o index.o
gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE  bedidx.c -o bedidx.o
ar -cru libtabix.a bgzf.o kstring.o knetfile.o index.o bedidx.o
ranlib libtabix.a
gcc -c -g -Wall -O2 -fPIC  -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE  main.c -o main.o
gcc -g -Wall -O2 -fPIC  -o tabix main.o -lm  -lz -L. -ltabix
./libtabix.a(bgzf.o): In function `deflate_block':
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:311: undefined reference to `deflate'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:313: undefined reference to `deflateEnd'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:305: undefined reference to `deflateInit2_'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:329: undefined reference to `deflateEnd'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:345: undefined reference to `crc32'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:346: undefined reference to `crc32'
./libtabix.a(bgzf.o): In function `inflate_block':
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:380: undefined reference to `inflateInit2_'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:385: undefined reference to `inflate'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:391: undefined reference to `inflateEnd'
/home/rob/src/github/freebayes/vcflib/tabixpp/bgzf.c:387: undefined reference to `inflateEnd'
./libtabix.a(bedidx.o): In function `ks_getuntil':
/home/rob/src/github/freebayes/vcflib/tabixpp/bedidx.c:11: undefined reference to `gzread'
./libtabix.a(bedidx.o): In function `bed_read':
/home/rob/src/github/freebayes/vcflib/tabixpp/bedidx.c:103: undefined reference to `gzdopen'
./libtabix.a(bedidx.o): In function `ks_getc':
/home/rob/src/github/freebayes/vcflib/tabixpp/bedidx.c:11: undefined reference to `gzread'
./libtabix.a(bedidx.o): In function `bed_read':
/home/rob/src/github/freebayes/vcflib/tabixpp/bedidx.c:138: undefined reference to `gzclose'
/home/rob/src/github/freebayes/vcflib/tabixpp/bedidx.c:103: undefined reference to `gzopen64'
collect2: ld returned 1 exit status
make[1]: *** [tabix] Error 1
make[1]: Leaving directory `/home/rob/src/github/freebayes/vcflib/tabixpp'
make: *** [all-recur] Error 1
@ekg
Copy link
Collaborator

ekg commented May 16, 2012

Did you obtain your copy of freebayes using git clone --recursive ... ?

@robsyme
Copy link
Author

robsyme commented May 17, 2012

Yes, the problem exists when using "git clone --recursive https://github.com/ekg/freebayes.git" or when trying to compile tabixpp on it's own. Let me know if I can supply any further information to help out.

rob-> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

@robsyme
Copy link
Author

robsyme commented May 17, 2012

I am an idiot. I assumed that tabix was already installed on this box, but it wasn't. Solution was:

sudo apt-get install tabix

So sorry for wasting your time. Hopefully this will help future fools :)

@robsyme robsyme closed this as completed May 17, 2012
@guillermo-carrasco
Copy link
Contributor

Hi,

I'm sorry, but I have exactly the same problem and the solution that @robsyme posted is not working for me. Compiling freebayes (once cloned using the --recursive option) or tabixpp alone gives me the following error: https://gist.github.com/3405009

Am I missing something?

Thank you very much

@ekg
Copy link
Collaborator

ekg commented Aug 20, 2012

Hi Guillermo,

Do you have zlib installed? (-lz). I think it's liblz-dev in ubuntu
12.10. I'm not sure which package in other distributions.

This might have been pulled in by @robsyme when he installed the tabix
package, thus resolving the issue. Tabix is included in the freebayes
distribution, so this action would just install dependencies which might be
required to build it.

Erik
On Aug 20, 2012 3:08 PM, "Guillermo Carrasco" notifications@github.com
wrote:

Hi,

I'm sorry, but I have exactly the same problem and the solution that
@robsyme https://github.com/robsyme posted is not working for me.
Compiling freebayes (once cloned using the --recursive option) or tabixpp
alone gives me the following error: https://gist.github.com/3405009

Am I missing something?

Thank you very much


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-7872153.

@guillermo-carrasco
Copy link
Contributor

Hi Erik,

Yes, I have zlib installed. In ubuntu 12.04 is called zlib1g-dev. This is why I'm confused, I think I have all the dependencies installed, but the compilation keeps rising this error. However I'm looking to my /usr/lib directory and I can't find the file zlib.so, which should be there... I have googled but I cannot find any explanation for this. I have tried to make a softlink from /lib/x86_64-linux-gnu/libz.so.1.2.3.4 to /usr/lib/libz.so, but doesn't seems to work.

Do you know if other users of ubuntu 12.04 x86_64 are having the same problem?

Thank you very much for your help.

@ekg
Copy link
Collaborator

ekg commented Aug 21, 2012

Hi Guillermo,

I don't know if other 12.04 users are having this issue. I don't have a
system available to test on. Are you having any issues installing other
tools which depend on zlib, such as bgzip?

Does this thread help:
http://stackoverflow.com/questions/3373995/usr-bin-ld-cannot-find-lz ? It
suggests that you may need to install the 32-bit development libraries,
lib32z1-dev.

Erik
On Aug 21, 2012 11:36 AM, "Guillermo Carrasco" notifications@github.com
wrote:

Hi Erik,

Yes, I have zlib installed. In ubuntu 12.04 is called zlib1g-dev. This is
why I'm confused, I think I have all the dependencies installed, but the
compilation keeps rising this error. However I'm looking to my /usr/lib
directory and I can't find the file zlib.so, which should be there... I
have googled but I cannot find any explanation for this. I have tried to
make a softlink from /lib/x86_64-linux-gnu/libz.so.1.2.3.4 to
/usr/lib/libz.so, but doesn't seems to work.

Do you know if other users of ubuntu 12.04 x86_64 are having the same
problem?

Thank you very much for your help.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-7898411.

@guillermo-carrasco
Copy link
Contributor

Hi Erik,

Thanks for the threat. In fact, it was not a problem of dependencies. Looking for the specific errors I finally found this thread that gave me the solution of the problem: http://stackoverflow.com/questions/2395355/linking-with-libpng-zlib

It looks like (copy&pase the answer from stackoverflow): "The linker only includes a .o from inside the .a if the .o is needed to satisfy a reference". So depending on the order you link the libraries, the linker includes or not some objects... wired.

The solution was to edit the file freebayes/vcflib/tabixpp/Makefile and put the -lz to the end of the link line, remaining like this one: https://gist.github.com/3416100

Maybe this is something you want to take into account? If you want, I can pull-request you with the changes (just if you want to change it, of course). I've tested it in a fresh installation and it has compiled without problems.

Anyway, thank you very much for your help :-)

@arrogantrobot
Copy link

I have been trying to coerce vcflib into cmake, and I have encountered this same issue with zlib not being added to the tabix archive. I just wanted to point out that this thread was of great help. I ended up explicitly linking zlib to the tabix library and things went great. The bits that got me through:

find_library(Z_LIB z)
target_link_libraries(tabixpp ${Z_LIB})

@garethlin
Copy link

Hi all

I've installed Freebayes onto fresh Ubuntu 12.04 installs twice now. Worked my way through these dependency issues the first time and documented them properly the second time..

The following should work..

sudo apt-get install git

sudo apt-get install cmake

sudo apt-get install tabix

git clone --recursive git://github.com/ekg/freebayes.git

make

I don't do the make install I just manually move the binaries to where I want them (/home/me/bin)

The first time around I also had problems with zlib - but it was actually fixed by an automatic update from Ubuntu.. no problems the second time round. So probably just get your updates if you see the zlib problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants