g++ fails to link to static library when compilation and link in single command


 
Thread Tools Search this Thread
Top Forums Programming g++ fails to link to static library when compilation and link in single command
# 1  
Old 03-13-2012
g++ fails to link to static library when compilation and link in single command

Hello All,
I've encountered a strange behaviour from g++ that doesn't make sense to me. Maybe you can shed some light on it:

I have a bunch of source files and want to compile them and link them with a static library liba.a located in /usr/local/lib64 into an executable

Approach 1 works fine:
Code:
g++ -c file1.cc
g++ -c file2.cc
g++ -c file3.cc
g++ -o executable file1.o file2.o file3.o -la

Approach 2 doesn't work:
Code:
g++ -o executable file1.cc file2.cc file3.cc -la

That causes a load of undefined references, It's a shame, because method 2 is what my makefile produces.
Can anyone tell me the difference between 1 and 2 and how to fix it?

Thanks a lot,
Bjorn
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

/var/adm/messages (insterface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages Apr 22 16:43:05 Prod-App1 in.routed: interface net0 to 172.16.101.1 turned off Apr 22 16:43:33 Prod-App1 mac: NOTICE: nxge0 link up, 1000 Mbps, full duplex Apr 22 16:43:34 Prod-App1 mac: NOTICE: nxge0 link... (2 Replies)
Discussion started by: javeedkaleem
2 Replies

2. Solaris

/var/adm/messages (interface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# cat /var/adm//messages Apr 20 03:10:01 Prod-App1 syslogd: line 25: WARNING: loghost could not be resolved Apr 20 08:24:18 Prod-App1... (0 Replies)
Discussion started by: javeedkaleem
0 Replies

3. UNIX for Advanced & Expert Users

Xserver shared library link is gone

I am administering an Xserver v10.6.8 and I updated the ports using Macports self update. I received this error when calling the program R dyld: Library not loaded: /opt/local/lib/libicuuc.48.dylib Referenced from: /opt/local/lib/R/lib/x86_64/libR.dylib Reason: image not found Trace/BPT... (2 Replies)
Discussion started by: godzilla07
2 Replies

4. UNIX and Linux Applications

Tomcat 6.0 fails to read symlink(symbolic link) file

Hello all experts, Im in a situation where Tomcat simply does not want to read this file through the symlink.... I checked permissions..OK Also checked file & tomcat owner...all OK. This is what I have my /tomcat/conf/Catalina/local/appname.xml <Context> <Resource name="jdbc/black" ... (3 Replies)
Discussion started by: KingaKoopa
3 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Symbolic link not allowed or link target not accessible

Hi everybody, I read about treads realted to this issue but they did not resovle issue given below. Please help me resolve issue given below I have html file under /srv/www/htdocs/actual_folder ls actual_folder/ test.html and following link works... (0 Replies)
Discussion started by: newbielgn
0 Replies

6. Linux

Linux Library symbolic link damaged

Hi, firstly I am not so familiar with linux and i think i have done some damage to the red hat server. It seems that now in command line I am unable to use any basic command whatsoever (ls, move, cp, bash, etc). I was trying to deploy an application and have changed the symbolic link (soft... (1 Reply)
Discussion started by: zaxx
1 Replies

7. UNIX for Dummies Questions & Answers

Difference between hard link and soft link

Hi Experts, Please help me out to find out difference between a hard link and a soft link. I am new in unix plz help me with some example commands ( for creating such links). Regards S.Kamakshi :) (2 Replies)
Discussion started by: kamakshi s
2 Replies

8. Solaris

link a library compiled with SC 5.9 on a machine with SC5.8

Is it possible to link a library compiled on Solaris 10 with SunCompiler 5.9 in a project compiled with SC 5.8 ? Is there an option to "downgrade" the SC5.9 => SC5.8 to be sure of the compatibility ? Thanks 4 your help (2 Replies)
Discussion started by: sarastus
2 Replies

9. UNIX for Dummies Questions & Answers

Difference between hard link and soft link in unix

Hi All, Can any one please explain me what is the difference between hard link and soft link in UNIX. Thanks in advance Raja Chokalingam. (2 Replies)
Discussion started by: RAJACHOKALINGAM
2 Replies

10. Programming

use gcc and link with a library

Hello, J have a problem when I use gcc: This comand works: gcc -shared -fpic -I/usr/include/sys -I/usr/include -L/usr/lib/librt.sl essai1.c mylib.sl but gcc I/usr/include/sys -I/usr/include -L/usr/lib/librt.sl essai2.c -o essai don't work. The first command creates a dynamique... (1 Reply)
Discussion started by: AUBERT
1 Replies
Login or Register to Ask a Question
list link(1m)															     list link(1m)

NAME
list link - Displays a list of all the soft links whose names match the link name that you specify SYNOPSIS
cdscp list link link-name [with attribute-name = attribute-value] ARGUMENTS
The full name of a specific soft link. The last simple name can contain wildcard characters. The name of a particular attribute. The value of a particular attribute. DESCRIPTION
The list link command displays a list of all the soft links whose names match the link name that you specify. The last simple name can contain wildcard characters. You can use a with attribute-name = attribute-value clause to limit output only to soft links whose attributes have values equal to the specified values. A space must precede and follow the = (equals sign). This command does not list the name of the directory, object entry, or other soft link to which the soft link points. Privilege Required You must have read permission to the directory that stores the soft link. If you use a with attribute-name = attribute-value clause in the command, you also need read or test permission to the selected soft links. NOTE
This command is replaced at Revision 1.1 by the dcecp command and may not be provided in future releases of DCE. EXAMPLE
The following command displays a list of all the soft links whose names begin with the letter l in the directory /.:/admin. cdscp> list link /.:/admin/l* LIST SOFTLINK /.../abc.com/admin AT 1991-10-15-15:54:38 lnk01 lnk02 lnk03 lnk04 lnk05 lnk06 RELATED INFORMATION
Commands: create link(1m), delete link(1m), remove link(1m), set link(1m), show link(1m) list link(1m)