Release libraries bigger than debug libraries
Hi
I have strange problem where my release libraries are bigger than my debug libraries. What's strange is that it only happens on one machine, for all my own libraries. I've done tests on the following machines with the exact same code base:
-> Windows 7, Qt 4.8.4 = release libraries smaller than debug libraries as expected
-> Ubuntu 10.04, Qt 4.8.4 = release libraries smaller than debug libraries as expected
-> Fedora 17, Qt 4.8.1 = release libraries BIGGER than debug libraries
As I've said the code and pro file are exactly the same on all machines. I have no idea on what can possibly cause this.
Here is the PRO file for one of the libraries:
Code:
TEMPLATE = lib
CONFIG(debug, debug|release) {
TARGET = QHexViewd
} else {
TARGET = QHexView
}
DESTDIR = $OUT_PWD/../../lib
DEFINES += QHEXVIEW_LIBRARY
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += QHexView.h QHexView_global.h
SOURCES += QHexView.cpp
And here is the beginning of the generated Makefile:
Code:
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DQHEXVIEW_LIBRARY -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
CXXFLAGS = -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I.
LINK = g++
LFLAGS = -Wl,-O1 -Wl,-z,relro -shared -Wl,-soname,libQHexView.so.1
LIBS = $(SUBLIBS) -L/usr/lib64 -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake-qt4
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
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
Any help or hints will be much appreciated.
Thanks
Jaco
Re: Release libraries bigger than debug libraries
hello Jaco,
I am not a linux user, but I searched the equivalent of dependency walker (windows) for *nix and found a perl script to list all dependencies:
http://www.redhat.com/archives/rhl-l.../msg01670.html
I hope this can help
Alain
Re: Release libraries bigger than debug libraries
Hi Alain
Thanks for the response. However the issue is not related to what the library is linking against, its the library itself that is really big that does not make sense. I don't link anything statically against it, everything is linked dynamic.
Quote:
Originally Posted by
alainstgt
Linux ships with something similar to Dependency Walker called ldd which shows nothing suspicious.
Re: Release libraries bigger than debug libraries
If you have -g in your CXXFLAGS then debug symbols are being inserted into your library which bloats your library.
Re: Release libraries bigger than debug libraries
Just for comparison, this is what an out-of-the-box Qt 4.8.4 on Linux does for a basic program in release mode:
Code:
DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
and debug:
Code:
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -g -Wall -W -D_REENTRANT $(DEFINES)
You need to find out where all the other cruft in the CXXFLAGS is coming from.
Re: Release libraries bigger than debug libraries
Hi
Thanks for the replies.
After my post I decided to get the Qt 4.8.4 sources and compile Qt myself. After compiling it, I set up as a new kit in Qt Creator and pointed qmake to the qmake I built from the 4.8.4 sources. When I rebuild everything against this newly compiled 4.8.4 version, the problem is gone.
The culprit was indeed the -g flag which inserted the debug symbols. Not sure why the 4.8.1 qmake created a Makefile with all the other garbage and the 4.8.4 does not. Here is the Makefile from 4.8.4 which gives me nice small release libs again.
Code:
CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
Just to be complete in case anyone else runs into this problem:
I also noticed that after I deployed the application with the big release libraries it does not run properly. Nothing is painted on any widgets and lots of these messages appears:
Code:
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x2a0007a
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x2a0007a
The reason for these messages is a bad Qt 4.8.1 linux distro according to http://qt-project.org/forums/viewthread/16819. Thus, I guess I have the same bad 4.8.1 linux distro over here which also has issues in qmake.
Thanks for the help again.
Jaco