LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-11-2007, 12:14 PM   #1
52cent
LQ Newbie
 
Registered: Apr 2007
Posts: 14

Rep: Reputation: 0
Compiling with Kdevelop


Hi, i installed Kdevelop on ubuntu. And when i try to execute my program called 'test', i get these errors:
Quote:
cd '/home/slimshady/kdevelop/test/debug' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" make -k
make all-recursive
Making all in doc
Making all in .
make[3]: Nothing to be done for `all-am'.
Making all in en
make[3]: Nothing to be done for `all'.
Making all in po
make[2]: Nothing to be done for `all'.
Making all in src
if g++ -DHAVE_CONFIG_H -I. -I/home/slimshady/kdevelop/test/src -I.. -I/usr/include/kde -I/usr/share/qt3/include -I. -DQT_THREAD_SUPPORT -D_REENTRANT -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -fno-builtin -g3 -fno-inline -O0 -g3 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -MT test.o -MD -MP -MF ".deps/test.Tpo" -c -o test.o /home/slimshady/kdevelop/test/src/test.cpp; then mv -f ".deps/test.Tpo" ".deps/test.Po"; else rm -f ".deps/test.Tpo"; exit 1; fi
/bin/bash ../libtool --silent --tag=CXX --mode=link g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -fno-builtin -g3 -fno-inline -O0 -g3 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -o test -R /usr/lib -R /usr/share/qt3/lib -R /usr/lib -L/usr/lib -L/usr/share/qt3/lib main.o test.o -lkdeui
test.o: In function `main':
/home/slimshady/kdevelop/test/src/test.cpp:8: multiple definition of `main'
main.o:/home/slimshady/kdevelop/test/src/main.cpp:39: first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 501 in main.o to 72 in test.o
main.o: In function `main':
main.cpp:(.text+0x118): undefined reference to `test::test()'
main.cpp:(.text+0x169): undefined reference to `test::test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x48): undefined reference to `test::~test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x50): undefined reference to `test::~test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x4c0): undefined reference to `non-virtual thunk to test::~test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x4c8): undefined reference to `non-virtual thunk to test::~test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x528): undefined reference to `non-virtual thunk to test::~test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x530): undefined reference to `non-virtual thunk to test::~test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x600): undefined reference to `virtual thunk to test::~test()'
test.o:(.rodata._ZTV4test[vtable for test]+0x608): undefined reference to `virtual thunk to test::~test()'
collect2: ld returned 1 exit status
make[2]: *** [test] Error 1
make[2]: Target `all' not remade because of errors.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
*** Exited with status: 2 ***
And also, i dont know what all those includes :
Quote:
#include "test.h"
#include <qlabel.h>
#include <kmainwindow.h>
#include <klocale.h>
#include "test.moc"
Do I have to insert them to my program? why cant i just use 'stdio'?

I have never programmed in linux before and dont know why the hell it's so complicated, isnt there an IDE which I can just press something like CTRL+F9 and the program runs, like in windows?

Last edited by 52cent; 04-11-2007 at 12:19 PM.
 
Old 04-11-2007, 12:34 PM   #2
clb
Member
 
Registered: Sep 2004
Location: UK
Distribution: Ubuntu
Posts: 117

Rep: Reputation: 16
KDevelop is such an IDE. Have you installed libtools? It is essential to KDevelop, otherwise strange errors occur.

What sort of program are you trying to write? If its a console app then most of those headers wont be needed, but if you want to use KDE libraries or the locale settings then you will need them.

I take it you are fairly well versed in C++ on Windows machines?
 
Old 04-11-2007, 01:04 PM   #3
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Quote:
test.o: In function `main':
/home/slimshady/kdevelop/test/src/test.cpp:8: multiple definition of `main'
main.o:/home/slimshady/kdevelop/test/src/main.cpp:39: first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 501 in main.o to 72 in test.o
You have two definitions of main one in main.cpp and one in test.cpp
 
Old 04-11-2007, 04:00 PM   #4
52cent
LQ Newbie
 
Registered: Apr 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
KDevelop is such an IDE. Have you installed libtools? It is essential to KDevelop, otherwise strange errors occur.
hmm I tried now to install libtools and I got:
Code:
Couldn't find any package whose name or description matched "libtools"
Quote:
What sort of program are you trying to write? If its a console app then most of those headers wont be needed, but if you want to use KDE libraries or the locale settings then you will need them.
I really dont have any idea. I was just trying to write simple program in c, using the basic libraries and functions of this language. it was something like:

Code:
#include <stdio.h>
int main()
{
printf(...);
scanf(..);
printf(...);
return 0;
}
Quote:
I take it you are fairly well versed in C++ on Windows machines?
Yes i know very well the standard programming (in C actually, C++ i have just now started to learn), in windows. But here Im all confused and dont know what the hell i should do just for make a program to run

Quote:
You have two definitions of main one in main.cpp and one in test.cpp
So... what do i need to do? can i just delete the existing main file? why even is it there for?

I really appreciate your help, and ill be happy if you can make this whole thing clearer to me.
 
Old 04-11-2007, 10:41 PM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
KDevelop helps to manage the projects for you. When you create a new project it will insert some dummy code for you which you van use a the basis of your program. It looks as if you have selected the "Simple KDE Application" This project has generated quite a few files.

To find what has been generated for you, go to the file tree and open the src folder. There will be nine files there are two *.cpp and one *.h There are others files that manage the user interface, icons etc. The file that you wanted to change is really the main.cpp (but it opens with the test.cpp)

However the better project to select from the (dauntingly long) list is "Simple Hello World Program" When you select a project you will find it under the C++ directory. However if it is not visible just click on the show all project templates.

This project will give you a simple (single file) pure C++ project.

Have fun.
 
Old 04-15-2007, 02:33 AM   #6
52cent
LQ Newbie
 
Registered: Apr 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Ok i went with "Simple Hello World Program" and i managed to run my program, but, can i add more files to this project? i tried to add a simple function in other file called 'second' which i inserted into the project, but when i ran the program i got errors, i tried to include a header file (.h) with the declaration of the function but it still didnt work. However when i insert the definition of the function (i.e the whole function) into the header file it does work.
Is it me doing something wrong or is it the project can handle just one file?

Here is the error i get:
Quote:
cd '/home/slimshady/kdevelop/slimshady/debug' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" make -k
cd . && /bin/bash ./config.status Makefile
config.status: creating Makefile
make all-recursive
Making all in src
cd .. && /bin/bash ./config.status src/Makefile depfiles
config.status: creating src/Makefile
config.status: executing depfiles commands
/bin/bash ../libtool --tag=CXX --mode=link g++ -O0 -g3 -o slimshady slimshady.o
g++ -O0 -g3 -o slimshady slimshady.o
slimshady.o: In function `main':
/home/slimshady/kdevelop/slimshady/src/slimshady.cpp:14: undefined reference to `function(int, int)'
collect2: ld returned 1 exit status
 
Old 04-15-2007, 02:34 AM   #7
52cent
LQ Newbie
 
Registered: Apr 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Ok i went with "Simple Hello World Program" and i managed to run my program, but, can i add more files to this project? i tried to add a simple function in other file called 'second' which i inserted into the project, but when i ran the program i got errors, i tried to include a header file (.h) with the declaration of the function but it still didnt work. However when i insert the definition of the function (i.e the whole function) into the header file it does work.
Is it me doing something wrong or is it the project can handle just one file?

Here is the error i get:
Quote:
cd '/home/slimshady/kdevelop/slimshady/debug' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" make -k
cd . && /bin/bash ./config.status Makefile
config.status: creating Makefile
make all-recursive
Making all in src
cd .. && /bin/bash ./config.status src/Makefile depfiles
config.status: creating src/Makefile
config.status: executing depfiles commands
/bin/bash ../libtool --tag=CXX --mode=link g++ -O0 -g3 -o slimshady slimshady.o
g++ -O0 -g3 -o slimshady slimshady.o
slimshady.o: In function `main':
/home/slimshady/kdevelop/slimshady/src/slimshady.cpp:14: undefined reference to `function(int, int)'
collect2: ld returned 1 exit status
 
Old 04-23-2007, 11:43 PM   #8
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Sorry for not replying earlier, I've been on the road for the last week, finally arrived home...

Yes you can add file to the project, (I've not actually got my Linux box on at the moment so I can't check the actual steps) The trick is to add the new file to the project. On the right panel there should be a project tab you can use this to add a file to the project. Behind the scenes the project is managed by make as so the new file is added to the list of files make needs to manage.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling kdevelop merchtemeagle Linux - Software 2 03-16-2005 01:33 PM
Compiling and Installing Kdevelop 3.0.4 inline.skater Linux - Software 0 06-10-2004 04:06 AM
compiling in kdevelop shyam_d_sundar Linux - Software 1 05-06-2004 04:11 AM
Problem compiling KDevelop 3 stonehurstX11 Linux - Software 7 03-13-2004 10:30 AM
errors compiling c++ in kdevelop adriaanbw Programming 2 09-13-2003 07:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration