Compilation failures using qmake + mingw / msvc

Matthias Pospiech <[email protected]> Tue, 17 Nov 2009 22:37:59 +0100
Newsgroups gmane.comp.gnu.source-highlight.general
Message-ID <[email protected]>
I have set up a qmake .pro file to make the libary without autoconf. 
(file attached)

You will see in the following issues, that moving away from autoconf and 
to windows problems
arise that indicate that the code could be improved in its plattform 
independence.
So I do not want to complain that it fails compilation, but want to give 
hints to improve the
plattform independence.

Using mingw I run into the following issues:

/source-highlight-3.1/lib/srchilite/settings.cpp:11: config.h: No such 
file or directory
/source-highlight-3.1/lib/srchilite/settings.cpp:37: error: 
`ABSOLUTEDATADIR' was not declared in this scope
C:/Programme/Qt/SDK/2009.04/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/io.h:176: 
error: too many arguments to function `int mkdir(const char*)'
/source-highlight-3.1/lib/srchilite/settings.cpp:90: error: at this 
point in file

so that complition is stopped at settings.cpp.

Compling with msvc-2005 is more problematic:

The following warnings are thrown very often
\source-highlight-3.1\lib\srchilite\fileutil.h(28) : warning C4290: C++ 
exception specification ignored except to indicate a function is not 
__declspec(nothrow)
\source-highlight-3.1\lib\srchilite\formatterparams.h(18) : warning 
C4099: 'srchilite::FormatterParams' : type name first seen using 'class' 
now seen using 'struct'
\source-highlight-3.1\lib\srchilite\sourcehighlighter.h(22) : see 
declaration of 'srchilite::FormatterParams'
\source-highlight-3.1\lib\srchilite\eventgenerator.h(31) : warning 
C4800: 'unsigned int' : forcing value to bool  'true' or 'false' 
(performance warning)

Here again config.h does not exist (which really does not exist in the 
libary, nor mingw system header files).
Is this file generated by autoconf?
lib\srchilite\settings.cpp(11) : fatal error C1083: Cannot open include 
file: 'config.h': No such file or directory

The following error is much more problematic.
lib\srchilite\sourcehighlightutils.cpp(15) : fatal error C1083: Cannot 
open include file: 'dirent.h': No such file or directory

This is a header file _only_ existing in gcc derived compilers. 
Wikipedia says about it "The function is not part of the C standard",
and it is not part of any Visual Studio compiler. This means that if you 
use this header it binds the libary code to gcc.
I have seen other files where I expect that they only exist in gcc, for 
example <sys/stat.h>, or rather only in unix systems.

lib\srchilite\versions.cpp(18) : error C2065: 'VERSION' : undeclared 
identifier
lib\srchilite\versions.cpp(22) : error C2065: 'LIBRARY_VERSION' : 
undeclared identifier
This means that some Preprocessor Variables were not defined, probably 
the same as ABSOLUTEDATADIR in the mingw compilation step.
Here porting from the old toolchain to the .pro file needs completed, 
but I am missing the necessary information.

You had asked why I want to compile using msvc and did not try your 
mingw compiled binaries.
Well, it is because I have also projects which currently work only with 
visual studio, and for my new project where this libary
would be included I do not want to limit myself to either mingw or msvc.

Best Regards,
Matthias Pospiech

_______________________________________________
Help-source-highlight mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-source-highlight
source-highlight.pro (text/plain, 7 KB)
CONFIG += release
CONFIG -= debug
CONFIG -= qt
CONFIG += thread warn_on

TEMPLATE = lib
CONFIG += dll
# CONFIG += staticlib

TARGET = source-highlight

# -------------------------------------------------
# Define Variables
# -------------------------------------------------
BINARY_NAME = TARGET
BUILD_DIR = build
BIN_DIR = bin

# -------------------------------------------------
# Auto select compiler
# -------------------------------------------------
win32-g++:      COMPILER = mingw
win32-msvc2005: COMPILER = msvc-2005
linux-g++:      COMPILER = gcc

message(Compiler Binary: $$QMAKE_CXX)
message(Compiler Path: $${COMPILER})

# -------------------------------------------------
win32 {
    RELEASE_SUFFIX =
    DEBUG_SUFFIX   = d
}

CONFIG(debug, debug|release) {
    SUFFIX_STR = $${DEBUG_SUFFIX}
}
else {
    SUFFIX_STR = $${RELEASE_SUFFIX}
}

# -------------------------------------------------
# Target Directory
# -------------------------------------------------
debug:DESTDIR = $${BIN_DIR}/$${COMPILER}/debug/
release:DESTDIR = $${BIN_DIR}/$${COMPILER}/release/

# -------------------------------------------------
# Executable Filename
# -------------------------------------------------
TARGET = $${BINARY_NAME}$${SUFFIX_STR}

# -------------------------------------------------
# Prepocessor Definitions
# -------------------------------------------------
win32{
	DEFINES += WIN32
	DEFINES += _WINDOWS
	debug {
		DEFINES += _DEBUG
	}
	release {
		DEFINES += NDEBUG
	}
}
DEFINES += NOMINMAX
DEFINES += BOOST_REGEX_DYN_LINK
DEFINES += _CRT_SECURE_NO_WARNINGS
# -------------------------------------------------
# Objects Directory
# -------------------------------------------------
debug{
	OBJECTS_DIR = $${BUILD_DIR}/$${BINARY_NAME}/debug/
}
release{
	OBJECTS_DIR = $${BUILD_DIR}/$${BINARY_NAME}/release/
}

# -------------------------------------------------
# Moc Directory
# -------------------------------------------------
MOC_DIR = $${BUILD_DIR}/$${BINARY_NAME}/

# -------------------------------------------------
# Ui Directory
# -------------------------------------------------
UI_DIR = $${BUILD_DIR}/$${BINARY_NAME}/ui

# -------------------------------------------------
# Include directories
# -------------------------------------------------
INCLUDEPATH += lib/srchilite \
	../boost_1_40_0 

# -------------------------------------------------
# Libaries
# -------------------------------------------------

contains($${COMPILER}, msvc-2005) {
    # dll
    # debug:  LIBS += -Llib/boost/regex/$${COMPILER}/debug -lboost_regex-vc80-mt-gd-1_40
    # release:LIBS += -Llib/boost/regex/$${COMPILER}/release -lboost_regex-vc80-mt-1_40
    # static
    debug:  LIBS += -Llib/boost/regex/$${COMPILER}/debug -llibboost_regex-vc80-mt-gd-1_40
    release:LIBS += -Llib/boost/regex/$${COMPILER}/release -llibboost_regex-vc80-mt-1_40
}

contains($${COMPILER}, mingw) {
    debug:  LIBS += -Llib/boost/regex/$${COMPILER}/debug -lboost_regex-mgw34-mt-d-1_40
    release:LIBS += -Llib/boost/regex/$${COMPILER}/release -lboost_regex-mgw34-mt-1_40
}


# -------------------------------------------------
# Sources
# -------------------------------------------------
	
SOURCES += lib/srchilite/bufferedoutput.cpp \ 
	lib/srchilite/ctagscollector.cpp \ 
	lib/srchilite/ctagsformatter.cpp \ 
	lib/srchilite/ctagsmanager.cpp \ 
	lib/srchilite/debuglistener.cpp \ 
	lib/srchilite/delimitedlangelem.cpp \ 
	lib/srchilite/doctemplate.cpp \ 
	lib/srchilite/fileinfo.cpp \ 
	lib/srchilite/formatter.cpp \ 
	lib/srchilite/formattermanager.cpp \ 
	lib/srchilite/highlightbuilderexception.cpp \ 
	lib/srchilite/highlightrule.cpp \ 
	lib/srchilite/highlightrulefactory.cpp \ 
	lib/srchilite/highlightstate.cpp \ 
	lib/srchilite/highlightstatebuilder.cpp \ 
	lib/srchilite/highlightstateprinter.cpp \ 
	lib/srchilite/highlighttoken.cpp \ 
	lib/srchilite/ioexception.cpp \ 
	lib/srchilite/langdefmanager.cpp \ 
	lib/srchilite/langelem.cpp \ 
	lib/srchilite/langelems.cpp \ 
	lib/srchilite/langelemsprinter.cpp \ 
	lib/srchilite/langmap.cpp \ 
	lib/srchilite/languageinfer.cpp \ 
	lib/srchilite/linenumgenerator.cpp \ 
	lib/srchilite/lineranges.cpp \ 
	lib/srchilite/namedsubexpslangelem.cpp \ 
	lib/srchilite/parserexception.cpp \ 
	lib/srchilite/preformatter.cpp \ 
	lib/srchilite/regexhighlightrule.cpp \ 
	lib/srchilite/regexpreprocessor.cpp \ 
	lib/srchilite/regexranges.cpp \ 
	lib/srchilite/regexrulefactory.cpp \ 
	lib/srchilite/settings.cpp \ 
	lib/srchilite/sourcefilehighlighter.cpp \ 
	lib/srchilite/sourcehighlight.cpp \ 
	lib/srchilite/sourcehighlighter.cpp \ 
	lib/srchilite/sourcehighlightutils.cpp \ 
	lib/srchilite/srcuntabifier.cpp \ 
	lib/srchilite/statelangelem.cpp \ 
	lib/srchilite/statestartlangelem.cpp \ 
	lib/srchilite/stopwatch.cpp \ 
	lib/srchilite/stringdef.cpp \ 
	lib/srchilite/stringlistlangelem.cpp \ 
	lib/srchilite/stringtable.cpp \ 
	lib/srchilite/stylefileparser.cpp \ 
	lib/srchilite/substfun.cpp \ 
	lib/srchilite/test_readtags_main.cpp \ 
	lib/srchilite/textstyle.cpp \ 
	lib/srchilite/textstylebuilder.cpp \ 
	lib/srchilite/textstyleformatter.cpp \ 
	lib/srchilite/textstyleformatterfactory.cpp \ 
	lib/srchilite/utils.cpp \ 
	lib/srchilite/vardefinitions.cpp \ 
	lib/srchilite/verbosity.cpp \ 
	lib/srchilite/versions.cpp \ 
	lib/srchilite/wordtokenizer.cpp	
	
HEADERS += bufferedoutput.h \ 
	chartranslator.h \ 
	colormap.h \ 
	colors.h \ 
	copyright.h \ 
	ctagscollector.h \ 
	ctagsformatter.h \ 
	ctagsmanager.h \ 
	debuglistener.h \ 
	delimitedlangelem.h \ 
	docgenerator.h \ 
	doctemplate.h \ 
	eventgenerator.h \ 
	fileinfo.h \ 
	fileutil.h \ 
	formatter.h \ 
	formatterfactory.h \ 
	formattermanager.h \ 
	formatterparams.h \ 
	highlightbuilderexception.h \ 
	highlightevent.h \ 
	highlighteventlistener.h \ 
	highlightrule.h \ 
	highlightrulefactory.h \ 
	highlightstate.h \ 
	highlightstatebuilder.h \ 
	highlightstateprinter.h \ 
	highlighttoken.h \ 
	instances.h \ 
	ioexception.h \ 
	keys.h \ 
	langdefmanager.h \ 
	langdefparser.h \ 
	langdefparserfun.h \ 
	langdefscanner.h	 \ 
	langelem.h \ 
	langelems.h \ 
	langelemsprinter.h \ 
	langmap.h \ 
	languageinfer.h \ 
	linebuffer.h \ 
	linenumgenerator.h \ 
	lineranges.h \ 
	matchingparameters.h \ 
	namedsubexpslangelem.h \ 
	outlangdefparser.h \ 
	outlangdefparserfun.h \ 
	outlangdefscanner.h \ 
	parserexception.h \ 
	parserinfo.h \ 
	parsestruct.h \ 
	parsestyles.h \ 
	preformatter.h \ 
	readtags.h \ 
	refposition.h \ 
	regexhighlightrule.h \ 
	regexpreprocessor.h \ 
	regexranges.h \ 
	regexrulefactory.h \ 
	reportbugs.h \ 
	settings.h \ 
	sourcefilehighlighter.h \ 
	sourcehighlight.h \ 
	sourcehighlighter.h \ 
	sourcehighlightutils.h \ 
	srcuntabifier.h \ 
	statelangelem.h \ 
	statestartlangelem.h \ 
	stopwatch.h \ 
	stringdef.h \ 
	stringlistlangelem.h \ 
	stringtable.h \ 
	stylecssparser.h \ 
	stylefileparser.h \ 
	stylekey.h \ 
	styleparser.h \ 
	substfun.h \ 
	textstyle.h \ 
	textstylebuilder.h \ 
	textstyleformatter.h \ 
	textstyleformattercollection.h \ 
	textstyleformatterfactory.h \ 
	textstyles.h \ 
	tostringcollection.h \ 
	utils.h \ 
	vardefinitions.h \ 
	verbosity.h \ 
	versions.h \ 
	wordtokenizer.h