473,320 Members | 2,006 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,320 software developers and data experts.

Problems with constructors

I am trying to compile the program from this page:

http://www.gtkmm.org/docs/gtkmm-2.4/...elloworld.html

I use this makefile:

all: main

main: helloworld.h helloworld.cc main.cc
g++ main.cc -o main `pkg-config gtkmm-2.4 --cflags --libs`

But when I compile I get:

/tmp/ccPWqvDE.o: In function `main':
main.cc:(.text+0x37): undefined reference to `HelloWorld::HelloWorld()'
main.cc:(.text+0x54): undefined reference to `HelloWorld::~HelloWorld()'
main.cc:(.text+0x67): undefined reference to `HelloWorld::~HelloWorld()'
collect2: ld returned 1 exit status
make: *** [main] Error 1

But I don't understand why since the constructors are specified.
Mar 30 '08 #1
2 1533
On Mar 30, 9:31 am, saneman <d...@sdf.comwrote:
I am trying to compile the program from this page:

http://www.gtkmm.org/docs/gtkmm-2.4/...sec-helloworld...

I use this makefile:

all: main

main: helloworld.h helloworld.cc main.cc
g++ main.cc -o main `pkg-config gtkmm-2.4 --cflags --libs`

But when I compile I get:

/tmp/ccPWqvDE.o: In function `main':
main.cc:(.text+0x37): undefined reference to `HelloWorld::HelloWorld()'
main.cc:(.text+0x54): undefined reference to `HelloWorld::~HelloWorld()'
main.cc:(.text+0x67): undefined reference to `HelloWorld::~HelloWorld()'
collect2: ld returned 1 exit status
make: *** [main] Error 1

But I don't understand why since the constructors are specified.
This is not a problem with your code but a problem with what you are
building.
Your code is in two files main.cc and helloworld.cc but you are only
building main.cpp

You should probably drop a note to a group that can help you get your
makefile set up correctly. As a temporary solution change the build
line to:

g++ main.cc helloworld.cc -o main `pkg-config gtkmm-2.4 --
cflags --libs`

Notice: ^^^^^^^^^^^^
Mar 30 '08 #2
Alf P. Steinbach wrote:
* saneman:
>I am trying to compile the program from this page:

http://www.gtkmm.org/docs/gtkmm-2.4/...elloworld.html
I use this makefile:

all: main

main: helloworld.h helloworld.cc main.cc
g++ main.cc -o main `pkg-config gtkmm-2.4 --cflags --libs`

But when I compile I get:

/tmp/ccPWqvDE.o: In function `main':
main.cc:(.text+0x37): undefined reference to `HelloWorld::HelloWorld()'
main.cc:(.text+0x54): undefined reference to `HelloWorld::~HelloWorld()'
main.cc:(.text+0x67): undefined reference to `HelloWorld::~HelloWorld()'
collect2: ld returned 1 exit status
make: *** [main] Error 1

But I don't understand why since the constructors are specified.

You have forgotten 'helloworld.cc' in the compilation command.
Cheers, & hth.,

- Alf
Ah is there someway to split this up in to targets or is this offtopic?
Mar 30 '08 #3

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

Similar topics

3
by: Rajesh Garg | last post by:
Can we have private constructors and destructors? IF yes what is the use of such constructors or destructors.....in the sense where can these be implemented in a system................. I have...
42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
1
by: Antuane | last post by:
I've got a class as follows, PUBLIC CLASS BaseClass Sub New() End Sub Sub New(byval cName as String) End Sub
5
by: jose luis fernandez diaz | last post by:
Hi, When I compiling the program below: #include <map> using namespace std; template<typename td1, typename td2, typename td3,typename td4> class Tarificador
6
by: Stephen Martinelli | last post by:
thanks for the help...just one more question.... can a class have more then two parameterized constructors?..i would like to be able to instanciate the class with a different number of...
10
by: John | last post by:
Trying to find out what is essential / optional, I made an extremely simple Class and Module combination to add two numbers. (see below) It appears that an empty constructor is needed n order to...
3
by: John | last post by:
Before anything else, thanks Marina, Workgroups and Ralf, for your help so far. I am now able to better define the question! After adding more console printout lines to CSum, I tried all...
18
by: __PPS__ | last post by:
Hello, I'm a university student and I'm preparing for my final today. I'm reading course notes, I found completely strange piece of code. It makes me laugh, I think the teacher needs to prepare...
22
by: Peter Morris [Droopy eyes software] | last post by:
Look at these two classes public class Test { public readonly string Name; public Test(string name)
0
by: Dijkstra | last post by:
Hi! I am writing a program in which I need to keep track of how many objects of a given class exists at a time. The task is to do it using templates. The objects to be counted are of the class Note:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.