You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, July 3rd 2012, 6:53pm

QtCreator as IDE for cross-compiling

Hello,

I hope in this section we can talk about QtCreator too.

I use QtCreator as IDE for plain C++ projects, with no Qt code at all.
I have a working project configured as standard x86.

Now I want to cross-compile it for arm (arm-linux-gnueabi-g++).
I've already cross-compiled all libraries needed and put everything into ~/arm.

I'm wondering how to setup QtCreator to cross-compile. I created a new toolchain but I can't select it because the combobox is disabled in the project window.

Even a command-line procedure is ok.
Or I might change the Makefile....

This is the .pro file:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -------------------------------------------------
# Project created by QtCreator 2010-11-18T12:10:20
# -------------------------------------------------

QT -= gui core
TARGET = webserver.wt
LIBS += -lzmq
LIBS += -L/usr/local/lib \
    -lwt \
    -lwthttp
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += \
    WebServerApplication.cpp \
    PanelList.cpp \
    CsvUtil.cpp \
    ChartConfig.cpp \
    ApplicationCommands.cpp
HEADERS += PanelList.h \
    CsvUtil.h \
    ChartConfig.h \
    ApplicationCommands.h


and the Makefile:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
####### Compiler, tools and options

CC            = gcc
CXX           = g++
DEFINES       = -DQT_NO_DEBUG
CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH       = -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/linux-g++ -I. -I../../../QtSDK/Desktop/Qt/4.8.1/gcc/include -I.
LINK          = g++
LFLAGS        = -Wl,-O1 -Wl,-rpath,/home/mark/QtSDK/Desktop/Qt/4.8.1/gcc/lib
LIBS          = $(SUBLIBS)  -L/home/mark/QtSDK/Desktop/Qt/4.8.1/gcc/lib -lzmq -L/usr/local/lib -lwt -lwthttp -lpthread 
AR            = ar cqs
RANLIB        = 
QMAKE         = /home/mark/QtSDK/Desktop/Qt/4.8.1/gcc/bin/qmake
TAR           = tar -cf
COMPRESS      = gzip -9f
COPY          = cp -f
SED           = sed
COPY_FILE     = $(COPY)
COPY_DIR      = $(COPY) -r
STRIP         = strip
INSTALL_FILE  = install -m 644 -p
INSTALL_DIR   = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE      = rm -f
SYMLINK       = ln -f -s
DEL_DIR       = rmdir
MOVE          = mv -f
CHK_DIR_EXISTS= test -d
MKDIR         = mkdir -p

####### Output directory

OBJECTS_DIR   = ./

####### Files

SOURCES       = WebServerApplication.cpp \
		PanelList.cpp \
		CsvUtil.cpp \
		ChartConfig.cpp \
		ApplicationCommands.cpp 
OBJECTS       = WebServerApplication.o \
		PanelList.o \
		CsvUtil.o \
		ChartConfig.o \
		ApplicationCommands.o
DIST          = ../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/unix.conf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/linux.conf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base.conf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/gcc-base-unix.conf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-base.conf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/common/g++-unix.conf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/qconfig.pri \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/modules/qt_webkit_version.pri \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_functions.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt_config.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/exclusive_builds.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_pre.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/release.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/default_post.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/gdb_dwarf_index.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/warn_on.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/qt.prf \
		../../../QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/features/unix/thread.prf \


########################## too long ######################

####### Sub-libraries

distclean: clean
	-$(DEL_FILE) $(TARGET) 
	-$(DEL_FILE) Makefile


check: first

mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

compiler_moc_header_make_all:
compiler_moc_header_clean:
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
	-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: 

####### Compile

WebServerApplication.o: WebServerApplication.cpp ApplicationCommands.h \
		ChartConfig.h \
		CsvUtil.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o WebServerApplication.o WebServerApplication.cpp

PanelList.o: PanelList.cpp PanelList.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o PanelList.o PanelList.cpp

CsvUtil.o: CsvUtil.cpp CsvUtil.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o CsvUtil.o CsvUtil.cpp

ChartConfig.o: ChartConfig.cpp ChartConfig.h \
		PanelList.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o ChartConfig.o ChartConfig.cpp

ApplicationCommands.o: ApplicationCommands.cpp ApplicationCommands.h \
		ChartConfig.h \
		CsvUtil.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o ApplicationCommands.o ApplicationCommands.cpp

####### Install

install:   FORCE

uninstall:   FORCE

FORCE:


Thank you in advance
Mark

2

Tuesday, October 9th 2012, 12:47am

The problem here is that Qt Creator (wrongly) assumes that a project using qmake as build system also will use Qt itself. While that sounds like a reasonable assumption on first sight, it makes your setup difficult. You have essentially three options: (a) use another build system (cmake, autotools, or the Generic Make project, at least for opening your projects - building could still use qmake/make), (b) actually install or build a Qt version suitable for your target and select that Qt version in the build settings (even if the final executable won't use it - btw, CONFIG -= qt is "cleaner" than QT -= core gui in the .pro file), (c) fake such a suitable Qt version by creating a script called 'qmake' that creates console output similare to what a "real" 'qmake -query' would produce, and create a dummy shared object (with no particular contents, or, a void foo() {}) with your target toolchain and call it libQtCore.so, and put those fake qmakes and libQtCore.so in a dummy directory hierarchy mimicing a "real" Qt installation, including the mkspecs dir. And maybe ask the developers to fix it.