473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

A question on linking

I have a C file that needs to be linked with a C++ library.
If i link using gcc, i get some unresolved references error.
If i link using g++,its getting linked perfectly.
Is it ok to link a C file with a C++ library with g++?
What are its implications?

if you think its off topic please indicate right channels.

Jul 26 '06 #1
4 1442
I believe it's ok to link it with the C++ linker.

The C linker isn't working because the C++ library function
names are mangled to support polymorphism. The C++
linker is aware of the C++ function name mangling and
thus you are able to do the linking with the C++ linker.

--
Papastefanos Serafeim
se******@otenet.gr
? "main()" <dn****@gmail.com?????? ??? ??????
news:11**********************@m79g2000cwm.googlegr oups.com...
>I have a C file that needs to be linked with a C++ library.
If i link using gcc, i get some unresolved references error.
If i link using g++,its getting linked perfectly.
Is it ok to link a C file with a C++ library with g++?
What are its implications?

if you think its off topic please indicate right channels.

Jul 26 '06 #2
main() wrote:
I have a C file that needs to be linked with a C++ library.
If i link using gcc, i get some unresolved references error.
If i link using g++,its getting linked perfectly.
Is it ok to link a C file with a C++ library with g++?
What are its implications?

if you think its off topic please indicate right channels.
It would be more on topic on gcc-help list, or a forum dedicated to the
operating system of your choice. It's likely that you would get the
same effect by using the C compiler to link, specifying the necessary
libraries explicitly.
Jul 26 '06 #3
"main()" <dn****@gmail.comwrites:
I have a C file that needs to be linked with a C++ library.
If i link using gcc, i get some unresolved references error.
If i link using g++,its getting linked perfectly.
Is it ok to link a C file with a C++ library with g++?
What are its implications?

if you think its off topic please indicate right channels.
Your question is about the compiler(s), not about the language(s).
Try gnu.gcc.help.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 26 '06 #4
"main()" <dn****@gmail.comwrote:
# I have a C file that needs to be linked with a C++ library.
# If i link using gcc, i get some unresolved references error.
# If i link using g++,its getting linked perfectly.
# Is it ok to link a C file with a C++ library with g++?
# What are its implications?

You might try using a C++ construct that looks something like
external "C" {...}
(check with C++ for the actual syntax) to interface C and C++.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Raining down sulphur is like an endurance trial, man. Genocide is the
most exhausting activity one can engage in. Next to soccer.
Jul 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Wolfgang | last post by:
I have a problem with linking my CPP Code under a irix6 machine (sgi, UNIX). In my CPP code I use some Functions which are written in Python. So its a kind of CPP wrapper for my Python functions In...
0
by: Dibyendu Roy | last post by:
Hi All, I build an object called "dblorcle" to connect to oracle database in Sun solaris box. This is built linking with various oracle ".a" (archived, for static linking) files come with standard...
7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
2
by: sunil | last post by:
Hi, We have lot of c and fortran archive libraries that have complex dependencies. We have different server tasks that use some of these libraries. We have developed a tool inhouse that links...
20
by: Steven T. Hatton | last post by:
I just read this in the description of how C++ is supposed to be implemented: "All external object and function references are resolved. Library components are linked to satisfy external...
0
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database...
6
by: Rudy Ray Moore | last post by:
I work with a multi-project workspace. One project (the "startup" project) has a "Configuration Type" of "Application (.exe)". The other 40 projects have a "Configuration Type" of "Static Library...
0
by: Rudy Ray Moore | last post by:
I've been having trouble getting incremental linking to work under Visual C++ .net 2003 7.1 for my multi-project workspace. Ronald Laeremans and Carl Daniel (and a few others) helped me figure it...
0
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when...
1
by: srikar | last post by:
what is the difference between static linking & dynamic linking, what are the advantages of each? How to perform static linking & Dynamic linking by using gcc -o liniking will be done , but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.