Project

General

Profile

Actions

Bug #2448

closed

LINK_FLAGS placed before object files during linking

Added by gureedo about 12 years ago. Updated over 11 years ago.

Status:
Fixed
Priority:
Normal
Category:
build_cmake
Target version:
ASK QUESTIONS IN Forums:

Description

LINK_FLAGS variable holds additional options for linking, such as some LDFLAGS and LIBS.
During linking cmake places this variable before object files and we got something like this:

/usr/bin/gcc -std=gnu99 -Wall -g -Wshadow -W -pedantic -L/usr/lib/x86_64-linux-gnu -lpcre
-export-dynamic CMakeFiles/lighttpd.dir/server.o CMakeFiles/lighttpd.dir/response.o
CMakeFiles/lighttpd.dir/connections.o CMakeFiles/lighttpd.dir/network.o 
CMakeFiles/lighttpd.dir/configfile.o CMakeFiles/lighttpd.dir/configparser.o 
CMakeFiles/lighttpd.dir/request.o CMakeFiles/lighttpd.dir/proc_open.o 
CMakeFiles/lighttpd.dir/buffer.o CMakeFiles/lighttpd.dir/log.o 
CMakeFiles/lighttpd.dir/keyvalue.o CMakeFiles/lighttpd.dir/chunk.o 
CMakeFiles/lighttpd.dir/http_chunk.o CMakeFiles/lighttpd.dir/stream.o 
CMakeFiles/lighttpd.dir/fdevent.o CMakeFiles/lighttpd.dir/stat_cache.o 
CMakeFiles/lighttpd.dir/plugin.o CMakeFiles/lighttpd.dir/joblist.o 
CMakeFiles/lighttpd.dir/etag.o CMakeFiles/lighttpd.dir/array.o 
CMakeFiles/lighttpd.dir/data_string.o CMakeFiles/lighttpd.dir/data_count.o 
CMakeFiles/lighttpd.dir/data_array.o CMakeFiles/lighttpd.dir/data_integer.o 
CMakeFiles/lighttpd.dir/md5.o CMakeFiles/lighttpd.dir/data_fastcgi.o 
CMakeFiles/lighttpd.dir/fdevent_select.o CMakeFiles/lighttpd.dir/fdevent_libev.o 
CMakeFiles/lighttpd.dir/fdevent_poll.o CMakeFiles/lighttpd.dir/fdevent_linux_sysepoll.o 
CMakeFiles/lighttpd.dir/fdevent_solaris_devpoll.o 
CMakeFiles/lighttpd.dir/fdevent_solaris_port.o 
CMakeFiles/lighttpd.dir/fdevent_freebsd_kqueue.o CMakeFiles/lighttpd.dir/data_config.o 
CMakeFiles/lighttpd.dir/bitset.o CMakeFiles/lighttpd.dir/inet_ntop_cache.o 
CMakeFiles/lighttpd.dir/crc32.o CMakeFiles/lighttpd.dir/connections-glue.o 
CMakeFiles/lighttpd.dir/configfile-glue.o CMakeFiles/lighttpd.dir/http-header-glue.o 
CMakeFiles/lighttpd.dir/splaytree.o CMakeFiles/lighttpd.dir/network_writev.o 
CMakeFiles/lighttpd.dir/network_write.o CMakeFiles/lighttpd.dir/network_linux_sendfile.o 
CMakeFiles/lighttpd.dir/network_freebsd_sendfile.o 
CMakeFiles/lighttpd.dir/network_solaris_sendfilev.o CMakeFiles/lighttpd.dir/network_openssl.o 
CMakeFiles/lighttpd.dir/status_counter.o  -o lighttpd -rdynamic -ldl

gcc manual says about -l flag: It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, `foo.o -lz bar.o' searches library `z' after file foo.o but before bar.o. If bar.o refers to functions in `z', those functions may not be loaded.

if i manually move LINK_FLAGS to end of command then linking completes succesfully.

software:
cmake v2.8.7
gcc v4.6.3
make v3.81

Actions #1

Updated by stbuehler over 11 years ago

  • Target version changed from 1.4.x to 1.4.33
Actions #2

Updated by stbuehler over 11 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100

Applied in changeset r2875.

Actions

Also available in: Atom