473,394 Members | 1,932 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,394 software developers and data experts.

Strange linking behaviour

Dear all,

I have a MyClass.h file with declarations and MyClass.cxx file with
definitions. From this I create a library libMyLib.a, containing
properly the MyClass.o object. When I try to link with MyExec.o,
containing the main function, I get an undefined reference for a MyClass
member function which can be eliminated if I move the definition from
the MyClass.cpp file to the MyClass.h file. What could be the cause of
this? Thanks,

filimon
Feb 3 '07 #1
2 1145
On 3 Feb, 16:17, Filimon Roukoutakis <fili...@phys.uoa.grwrote:
Dear all,

I have a MyClass.h file with declarations and MyClass.cxx file with
definitions. From this I create a library libMyLib.a, containing
properly the MyClass.o object. When I try to link with MyExec.o,
containing the main function, I get an undefined reference for a MyClass
member function which can be eliminated if I move the definition from
the MyClass.cpp file to the MyClass.h file. What could be the cause of
this? Thanks,

filimon
Does it matter where in the .h file you move it to? I'm thinking
perhaps in one file you have it within a class, or a namespace, or an
extern "C", or the like, and when you move it you don't. Otherwise, I
think you are going to have to post some code - just whittle it down
to the the smallest length of file that goes wrong.

Paul.

Feb 3 '07 #2
Hi, the problem was related to KDevelop make configuration for building
libraries, it is fixed now. Thanks,

filimon

gw****@aol.com wrote:
On 3 Feb, 16:17, Filimon Roukoutakis <fili...@phys.uoa.grwrote:
>Dear all,

I have a MyClass.h file with declarations and MyClass.cxx file with
definitions. From this I create a library libMyLib.a, containing
properly the MyClass.o object. When I try to link with MyExec.o,
containing the main function, I get an undefined reference for a MyClass
member function which can be eliminated if I move the definition from
the MyClass.cpp file to the MyClass.h file. What could be the cause of
this? Thanks,

filimon

Does it matter where in the .h file you move it to? I'm thinking
perhaps in one file you have it within a class, or a namespace, or an
extern "C", or the like, and when you move it you don't. Otherwise, I
think you are going to have to post some code - just whittle it down
to the the smallest length of file that goes wrong.

Paul.
Feb 3 '07 #3

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

Similar topics

1
by: Wouter | last post by:
Hi all, I'm creating a DLL which contains a certain class ( class A), but i forgot to export it. I created instances from this class in the DLL and passed a pointers to the executable. I then...
5
by: Arnab Nandi | last post by:
We are using the Sun Workshop 6 C++ compiler to compile some CPP files. The command line looks like follows: - CC -g -xsb -c -o output/x.o x.cpp We get the following error: - CC: language...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
31
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
2
by: teddysnips | last post by:
We've been supporting a number of Access applications for a particular client for some years. Some of them were written by third parties, some by us (even one or two by me, though not this...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
1
by: agarwasa2008 | last post by:
Hi, I have a perfect file called "Products.xls" that I link to my MS Access 2003 database and everytthing looks good in that file. When I view the same file after linking in my database the...
20
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code -----------------------------------...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.