Reply to topic

[Newbee]Build environment problem

marcux
Registered Member
Posts
3
Karma
0

[Newbee]Build environment problem

Tue Oct 15, 2013 3:18 pm
Hi all!
I have been following the tutorial hello world:
http://techbase.kde.org/Development/Tutorials/First_program

My program will pass through cmake but will not compile with make.
I have tried to set path and tried the .build-config file.
I have tried to install Qt5 and changed path to /home/marcux/Qt5.1.1/5.1.1/gcc_64/include/QtCore
I have tried to compile with: g++ -I/usr/include/kde4/KDE -I/usr/include/kde4 main.cpp
same error.

I use Fedora 19 with kde.

Can someone please guide me in the right direction?

Many thanks in advance!

Code: Select all
[  0%] Built target tutorial1_automoc
Linking CXX executable tutorial1
CMakeFiles/tutorial1.dir/main.o: In function `QByteArray::~QByteArray()':
/usr/include/QtCore/qbytearray.h:401: undefined reference to `qFree(void*)'
CMakeFiles/tutorial1.dir/main.o: In function `QString::~QString()':
/usr/include/QtCore/qstring.h:880: undefined reference to `QString::free(QString::Data*)'
CMakeFiles/tutorial1.dir/main.o: In function `i18n(char const*)':
/usr/include/kde4/klocalizedstring.h:632: undefined reference to `ki18n(char const*)'
/usr/include/kde4/klocalizedstring.h:632: undefined reference to `KLocalizedString::toString() const'
/usr/include/kde4/klocalizedstring.h:632: undefined reference to `KLocalizedString::~KLocalizedString()'
CMakeFiles/tutorial1.dir/main.o: In function `main':
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `QByteArray::QByteArray(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `QByteArray::QByteArray(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `ki18n(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `ki18n(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `ki18n(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `QByteArray::QByteArray(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `ki18n(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `QByteArray::QByteArray(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `QByteArray::QByteArray(char const*)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `KAboutData::KAboutData(QByteArray const&, QByteArray const&, KLocalizedString const&, QByteArray const&, KLocalizedString const&, KAboutData::LicenseKey, KLocalizedString const&, KLocalizedString const&, QByteArray const&, QByteArray const&)'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `KLocalizedString::~KLocalizedString()'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `KLocalizedString::~KLocalizedString()'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `KLocalizedString::~KLocalizedString()'
/home/marcux/projects/helloworld/main.cpp:17: undefined reference to `KLocalizedString::~KLocalizedString()'
/home/marcux/projects/helloworld/main.cpp:19: undefined reference to `KCmdLineArgs::init(int, char**, KAboutData const*, QFlags<KCmdLineArgs::StdCmdLineArg>)'
/home/marcux/projects/helloworld/main.cpp:20: undefined reference to `KApplication::KApplication(bool)'
CMakeFiles/tutorial1.dir/main.o: In function `QString':
/usr/include/QtCore/qstring.h:879: undefined reference to `QString::shared_null'
CMakeFiles/tutorial1.dir/main.o: In function `QBasicAtomicInt::ref()':
/usr/include/QtCore/qatomic_x86_64.h:121: undefined reference to `QString::shared_null'
CMakeFiles/tutorial1.dir/main.o: In function `main':
/home/marcux/projects/helloworld/main.cpp:23: undefined reference to `KGuiItem::KGuiItem(QString const&, QString const&, QString const&, QString const&)'
CMakeFiles/tutorial1.dir/main.o: In function `QString':
/usr/include/QtCore/qstring.h:879: undefined reference to `QString::shared_null'
CMakeFiles/tutorial1.dir/main.o: In function `QBasicAtomicInt::ref()':
/usr/include/QtCore/qatomic_x86_64.h:121: undefined reference to `QString::shared_null'
CMakeFiles/tutorial1.dir/main.o: In function `main':
/home/marcux/projects/helloworld/main.cpp:25: undefined reference to `KStandardGuiItem::no()'
/home/marcux/projects/helloworld/main.cpp:25: undefined reference to `KMessageBox::questionYesNo(QWidget*, QString const&, QString const&, KGuiItem const&, KGuiItem const&, QString const&, QFlags<KMessageBox::Option>)'
/home/marcux/projects/helloworld/main.cpp:25: undefined reference to `KGuiItem::~KGuiItem()'
/home/marcux/projects/helloworld/main.cpp:23: undefined reference to `KGuiItem::~KGuiItem()'
/home/marcux/projects/helloworld/main.cpp:20: undefined reference to `KApplication::~KApplication()'
/home/marcux/projects/helloworld/main.cpp:26: undefined reference to `KAboutData::~KAboutData()'
collect2: fel: ld returnerade avslutningsstatus 1
make[2]: *** [tutorial1] Fel 1
make[1]: *** [CMakeFiles/tutorial1.dir/all] Fel 2
make: *** [all] Fel 2
puller
Registered Member
Posts
19
Karma
0
OS
You are getting errors from the linker.
It cannot find some of the objects file that define the symbols reported in the errors.

Can you post the CMakeLists.txt file that you are using?
You should be able to set the libraries to be linked directly in there.

Anyway, your g++ attempt is wrong, you should use -L</path/to/shared/objects> -l<sharedobjectname>.

For example, if you want to link against "libsupport.so" which is in /home/marcux/mylibs, you should use:
Code: Select all
g++ main.cpp -L/home/marcux/mylibs -lsupport

(not that "lib" and ".so" are not needed when passing the library name to the linker).
marcux
Registered Member
Posts
3
Karma
0
Hello!
Here is my CMakeLists.txt:

Code: Select all
project(tutorial1)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
include_directories(${KDE4_INCLUDES})
set(tutorial1_SRCS main.cpp)
kde4_add_executable(tutorial1 ${tutorial1_SRCS})
target_link_libraries(tutorial1 ${KDE_KDEUI_LIBS})
install(TARGETS tutorial1 ${INSTALL_TARGETS_DEFAULT_ARGS})


and here is my .build-config file:

Code: Select all
# KDE4 Build Environment configuration script
#
# To configure your build environment set LIB_SUFFIX, BASEDIR, BUILDNAME and
# QTDIR as appropriate
#
# The default values provided are for a master/trunk/unstable build in your own
# user directory using your system Qt
 
# Uncomment if building on a 64 bit system
export LIB_SUFFIX=64
 
# Set where your base KDE development folder is located, usually ~/kde
export BASEDIR=~/kde
 
# Give the build a name, e.g. master, 4.6, debug, etc
export BUILDNAME=master
 
# Set up which Qt to use
# Use the system Qt, adjust path as required
export QTDIR=/usr/include/Qt
# Uncomment to use your own build of qt-kde
#export QTDIR=$BASEDIR/inst/master/qt-kde
#export PATH=$QTDIR/bin:$PATH
#export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
#export PKG_CONFIG_PATH=$QTDIR/lib/pkgconfig:$PKG_CONFIG_PATH
 
# Set up the KDE paths
export KDE_SRC=$BASEDIR/src
export KDE_BUILD=$BASEDIR/build
export KDEDIR=$BASEDIR/inst/$BUILDNAME
export KDEDIRS=$KDEDIR
export KDEHOME=$BASEDIR/home/.$BUILDNAME
export KDETMP=/tmp/$BUILDNAME-$USER
export KDEVARTMP=/var/tmp/$BUILDNAME-$USER
mkdir -p $KDETMP
mkdir -p $KDEVARTMP
 
# Add the KDE plugins to the Qt plugins path
export QT_PLUGIN_PATH=$KDEDIR/lib/kde4/plugins
 
# Do we really need these?
export KDE4_DBUS_INTERFACES_DIR=$KDEDIR/share/dbus-1/interfaces
export PYTHON_SITE_PACKAGES_DIR=$KDEDIR/lib/python2.6/site-packages/PyKDE4
 
# Export the standard paths to include KDE
export PATH=$KDEDIR/bin:$PATH
export LD_LIBRARY_PATH=$KDEDIR/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$KDEDIR/lib/pkgconfig:$PKG_CONFIG_PATH
 
# Export the CMake paths so it searches for KDE in the right places
export CMAKE_PREFIX_PATH=$KDEDIR:$CMAKE_PREFIX_PATH
export CMAKE_LIBRARY_PATH=$KDEDIR/lib:$CMAKE_LIBRARY_PATH
export CMAKE_INCLUDE_PATH=$KDEDIR/include:$CMAKE_INCLUDE_PATH
 
# Unset XDG to avoid seeing KDE files from /usr
# If unset then you must install shared-mime-info
unset XDG_DATA_DIRS
unset XDG_CONFIG_DIRS
 
# Uncomment if you are using Icecream for distributed compiling
#export PATH=/opt/icecream/bin:$PATH
 
# Report what the environment is set to
echo
echo "*** Configured KDE Build Environment " $BUILDNAME " ***"
echo
echo "QTDIR=" $QTDIR
echo "KDEDIR=" $KDEDIR
echo "PATH=" $PATH
echo


It seems as if cmake finds the right paths.
Here is my output from cmake:
Code: Select all
$ cmake .
-- Found Qt-Version 4.8.5 (using /usr/bin/qmake-qt4)
-- Found X11: /usr/lib64/libX11.so
-- Found KDE 4.11 include dir: /usr/include/kde4
-- Found KDE 4.11 library dir: /usr/lib64/kde4/devel
-- Found the KDE4 kconfig_compiler4 preprocessor: /usr/bin/kconfig_compiler4
-- Found automoc4: /usr/bin/automoc4
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marcux/projects/helloworld


I hope you can help me.
Many thanks!
puller
Registered Member
Posts
19
Karma
0
OS
I don't understand why KDE_KDEUI_LIBS should be something other than an empty variable :)!
But maybe that's because I don't know what the kde build system is doing behind the scenes.

Anyway, you can try to source your .build-config file:
Code: Select all
source .build-config

then (if you have setu-up a KDE build env) try to compile again with
Code: Select all
kdebuild


Also, make sure to have all the libraries installed!
marcux
Registered Member
Posts
3
Karma
0
I have done:
yum groupinstall 'Development Tools'
I have double checked that I have :
kdelibs-devel, kde-baseapps-devel

I have put: source .build-config
in my .bachrc file.

I have followed the helloworld tutorial.

I can not run kdebuild, do I need to run that to compile helloworld?
I have followed the instructions in:
http://techbase.kde.org/Getting_Started ... nvironment
for my build environment.

Do I need any more libraries?
What am I missing?

Many thanks!
puller
Registered Member
Posts
19
Karma
0
OS
I just tried doing the same tutorial, so I created two files, main.cpp and CMakeLists.txt, copied and pasted the content from the tutorial page, then run

Code: Select all
cmake .
make


and everything worked flawlessly :-\ .

Code: Select all
vince@vince-VPCSB1C5E:~/Desktop/kde_hellp$ cmake .
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt-Version 4.8.4 (using /usr/bin/qmake-qt4)
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so;/usr/lib/x86_64-linux-gnu/libXft.so;/usr/lib/x86_64-linux-gnu/libXau.so;/usr/lib/x86_64-linux-gnu/libXdmcp.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so;/usr/lib/x86_64-linux-gnu/libXft.so;/usr/lib/x86_64-linux-gnu/libXau.so;/usr/lib/x86_64-linux-gnu/libXdmcp.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Looking for _POSIX_TIMERS
-- Looking for _POSIX_TIMERS - found
-- Found Automoc4: /home/vince/kde/inst/master/bin/automoc4 
-- Found Perl: /usr/bin/perl (found version "5.14.2")
-- Found Phonon: /usr/include/qt4 (Required is at least version "4.3.80")
-- Performing Test _OFFT_IS_64BIT
-- Performing Test _OFFT_IS_64BIT - Success
-- Performing Test HAVE_FPIE_SUPPORT
-- Performing Test HAVE_FPIE_SUPPORT - Success
-- Performing Test __KDE_HAVE_W_OVERLOADED_VIRTUAL
-- Performing Test __KDE_HAVE_W_OVERLOADED_VIRTUAL - Success
-- Performing Test __KDE_HAVE_GCC_VISIBILITY
-- Performing Test __KDE_HAVE_GCC_VISIBILITY - Success
-- Found KDE 4.12 include dir: /home/vince/kde/inst/master/include
-- Found KDE 4.12 library dir: /home/vince/kde/inst/master/lib
-- Found the KDE4 kconfig_compiler preprocessor: /home/vince/kde/inst/master/bin/kconfig_compiler
-- Found automoc4: /home/vince/kde/inst/master/bin/automoc4
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vince/Desktop/kde_hellp
vince@vince-VPCSB1C5E:~/Desktop/kde_hellp$ make
makeobj[0]: Entering directory `/home/vince/Desktop/kde_hellp'
Scanning dependencies of target tutorial1_automoc
[  0%] Built target tutorial1_automoc
Scanning dependencies of target tutorial1
[ 50%] Building CXX object CMakeFiles/tutorial1.dir/tutorial1_automoc.o
[100%] Building CXX object CMakeFiles/tutorial1.dir/main.o
Linking CXX executable tutorial1
[100%] Built target tutorial1
makeobj[0]: Leaving directory `/home/vince/Desktop/kde_hellp'
vince@vince-VPCSB1C5E:~/Desktop/kde_hellp$ ls
CMakeCache.txt  cmake_install.cmake  CMakeTmp               CTestTestfile.cmake  Makefile   tutorial1_automoc.cpp        tutorial1.shell
CMakeFiles      CMakeLists.txt       cmake_uninstall.cmake  main.cpp             tutorial1  tutorial1_automoc.cpp.files


Note the line "Found KDE 4.12 library dir: /home/vince/kde/inst/master/lib".

That path is where I have all my libraries compiled.
User avatar bcooksley
Administrator
Posts
18669
Karma
83
OS
Please post the output of the following commands:
Code: Select all
cat CMakeCache.txt | grep KDEUI_LIBS

Code: Select all
VERBOSE=1 make

Both these commands should be run in the directory where you invoked CMake to configure your project to build.


System Settings and Device Actions KCM maintainer
Image

 
Reply to topic

Bookmarks



Who is online

Registered users: Alastair, apater, Baidu [Spider], Bing [Bot], Exabot [Bot], garthecho, ggael, Google [Bot], google01103, Horus, jitseniesen, Joif, kde-jriddell, ken300, La Ninje, Mamarok, mmistretta, Nuc!eoN, psbot [Picsearch], rbruce, renatoatilio, sacarde, sinclair, stephans, TheraHedwig, tienhung, wolfi323, Yahoo [Bot]