LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Compiling with Kdevelop (https://www.linuxquestions.org/questions/programming-9/compiling-with-kdevelop-545163/)

52cent 04-11-2007 12:14 PM

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?

clb 04-11-2007 12:34 PM

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?

dmail 04-11-2007 01:04 PM

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

52cent 04-11-2007 04:00 PM

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 :cry:

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.

graemef 04-11-2007 10:41 PM

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.

52cent 04-15-2007 02:33 AM

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

52cent 04-15-2007 02:34 AM

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

graemef 04-23-2007 11:43 PM

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.


All times are GMT -5. The time now is 01:34 PM.