02-29-2008
What is the proper way to combine C++ files (with g++) to avoid link (ld) errors?
Problem background:
gcc v 4.1
2 .cpp files, 2 .h files
Files:
main.cpp
a.cpp
a.h
b.h
Organization:
main.cpp includes a.h (because it calls a.cpp code)
a.cpp includes a.h
a.h includes b.h (because a class in a.h uses a b.h class)
There is no inheritance between a.h or b.h or any of the classes.
The problem is that when I try to compile the files like
g++ main.cpp a.cpp
I get an bunch of linker errors like "duplicate symbol X found..." which are for symbols from b.h
Normally I would think this is due to there not being #ifndef or #pragma once guards, but there are "#pragma once" things at the top of all the .h files. To me it seems like what is happening is that gcc is generating main.o separately from a.o and then then ld is called it sees duplication of symbols and it errors out. What is the correct way to tell g++ to compile them both while looking at them both?
I would think it would be something like --combine, but the man page and testing show that's only valid for C files.
I have also tried -shared which makes ld not complain but which says it's for making a shared library, so it doesn't seem correct for building an executable. Will using -shared lead to any strange behavior down the road (I need to know now since the application itself isn't in a state that I can test it, and I don't want to end up finding out it was the -shared flag's fault)
I have also tried -fwhole-program, which again works, but the man page says it's for optimization, so that also doesn't seem correct. Same question with regards to possible weird behavior down the road.
Thanks much for any help.
John
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
$ errpt | more
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR
B8113DD1 ... (0 Replies)
Discussion started by: mcastill66
0 Replies
2. AIX
$ errpt | more
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
B8113DD1 0802050205 T H fcs1 LINK ERROR
3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR
B8113DD1 ... (2 Replies)
Discussion started by: mcastill66
2 Replies
3. Shell Programming and Scripting
Hi all,
I am running a script on bash shell, although it gives me the desired output, it displays some errors at the prompt like
this directory doesnt exists
unary operator
etc etc
Is there someway to avoid these errors ??
Its very annoying to have these errors while the script is... (4 Replies)
Discussion started by: vikas027
4 Replies
4. Shell Programming and Scripting
Using Solaris 10 and sh.
I have three files.
mydirs.txt
/dir1/dir2/dir3
/dir4/dir5/dir6
mydirshave.txt
1
2
mydirsshouldhave.txt
2
2
For each directory listed in mydirs.txt I should have the number of files equal to mydirshouldhave.txt. But using -ls |wc -l- on the dirs I get what... (2 Replies)
Discussion started by: crowman
2 Replies
5. Solaris
Hello,
this is solaris 10 on SF v440,
I know below errors might go away if I put a new PS or put the original one back in socket but is there any other way to stop these errors from appearing in /var/adm/messages ? I do not want to put the failed PS1 in socket neither do we want to spend on... (5 Replies)
Discussion started by: upengan78
5 Replies
6. AIX
Hi Can any suggest me how to work on this particular issue i am facing.
Below is the error message received on vio servers.
IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION
4B436A3D 0326102912 T H fscsi1 LINK ERROR
4B436A3D 0325212712 T H fscsi1 LINK ERROR
4B436A3D... (2 Replies)
Discussion started by: ganiiee
2 Replies
7. Shell Programming and Scripting
Hello Guys,
I have a file say FILE1.txt contains below data:-
A
B
C
D
E
F
G
H
I
J
K
L
I need the output in another file as FILE2 as:-
'A', 'B', 'C', 'D', 'E', (7 Replies)
Discussion started by: jassi10781
7 Replies
8. UNIX for Advanced & Expert Users
Any help appreciated just logging in to this server which is a front end for Rocks Cluster 6.1.1. Getting the below errors:
ldconfig
ldconfig: /usr/lib/libX11.so.6 is not a symbolic link
ldconfig: /usr/lib/libjpeg.so.62 is not a symbolic link
ldconfig: /usr/lib/libpng12.so.0 is not a symbolic... (3 Replies)
Discussion started by: RobbieTheK
3 Replies
9. UNIX for Beginners Questions & Answers
i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies
10. AIX
I am building a bff using mkinstallp.
My template file is :
Package Name: svr_exForum
Package VRMF: 7.2
Update: N
Fileset
Fileset Name: svr_exForum.rte
Fileset VRMF: 7.2
USRLIBLPPFiles
Pre-installation Script: /lppdir/lpp/exForum/F_pre_i
... (2 Replies)
Discussion started by: kevinl
2 Replies
LEARN ABOUT DEBIAN
sessions
RTP
sessions.(3) Library Functions Manual RTP sessions.(3)
NAME
RTP sessions. -
Classes
class TRTPSessionBase< RTPDataChannel, RTCPChannel, ServiceQueue >
class SingleThreadRTPSession< RTPDataChannel, RTCPChannel, ServiceQueue >
This template class adds the threading aspect to the RTPSessionBase template in one of the many possible ways.
class RTPSessionBase
Generic RTP protocol stack for exchange of realtime data.
Typedefs
typedef SingleThreadRTPSession RTPSession
Uses two pairs of sockets for RTP data and RTCP transmission/reception.
typedef RTPSession RTPSocket
Alias for RTPSession.
typedef SingleThreadRTPSession
< SymmetricRTPChannel,
SymmetricRTPChannel > SymmetricRTPSession"
Uses one pair of sockets, (1) for RTP data and (2) for RTCP transmission/reception.
Detailed Description
Typedef Documentation
RTPSession
Uses two pairs of sockets for RTP data and RTCP transmission/reception. UDP/IPv4 RTP Session scheduled by one thread of execution.
Examples:
audiorx.cpp, audiotx.cpp, ccrtptest.cpp, rtphello.cpp, rtplisten.cpp, and rtpsend.cpp.
RTPSocket
Alias for RTPSession.
SymmetricRTPSession
Uses one pair of sockets, (1) for RTP data and (2) for RTCP transmission/reception. Symmetric UDP/IPv4 RTP session scheduled by one thread
of execution.
Author
Generated automatically by Doxygen for ccRTP from the source code.
ccRTP Sat Jun 23 2012 RTP sessions.(3)