<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Shared Lib und Testapplikation]]></title><description><![CDATA[<p>Hallo!</p>
<p>Es geht um C++ in Zusammenhang mit CMake. Da es eher C++ ist, habe ich dieses<br />
Forum gewählt: Ich compiliere eine eigene Library mit Hilfe von CMake, wobei<br />
in der CMakeLists.txt, das hier verwendet wird:</p>
<p>add_definitions(-O3 -Wextra -Wunused -Wall -ansi -pedantic-errors -frounding-math -g )</p>
<p>Wird nun die Test-Applikation, die diese Library verwendet, mit den gleichen<br />
Optionen compiliert, so funktioniert sie. Verwende ich aber für die Applikation</p>
<p>add_definitions(-O3 -Wextra -Wunused -Wall -ansi -pedantic-errors -frounding-math -DNDEBUG )</p>
<p>so gibt es Segfaults, und das hängt sicher nicht mit den Assertions zusammen.<br />
Mir scheint, daß der Code dann inkompatibel wird. Kann es sein, daß ich da<br />
noch Compiler-/Linkerflags wie -fPIC oder andere benötige?</p>
<p>Hier folgt die gesamte CMakeLists.txt für die Library. Jeder Hinweis wird<br />
dankend angenommen. Ich starte gerade erst mit CMake.</p>
<pre><code>cmake_minimum_required(VERSION 2.6)

# Name of the project 
project(FD_2D)

set(CMAKE_VERBOSE_MAKEFILE ON)

# Find boost
FIND_PACKAGE( Boost COMPONENTS program_options filesystem system REQUIRED )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )

add_definitions(-O3 -Wextra -Wunused -Wall -ansi -pedantic-errors -frounding-math -g )

set(LIB_SRC HCube2.cpp FD_2D.cpp Circle2.cpp Label.cpp Segment2.cpp ExactTest.cpp tools.cpp Color.cpp Dt2.cpp Vis2.cpp )
add_library(fd2d SHARED ${LIB_SRC})

TARGET_LINK_LIBRARIES( dt2 ${Boost_LIBRARIES} )

# install library
INSTALL( TARGETS fd2d DESTINATION lib PERMISSIONS
	OWNER_READ OWNER_WRITE OWNER_EXECUTE
	GROUP_READ GROUP_EXECUTE
	WORLD_READ WORLD_EXECUTE 
	)

# install headers
INSTALL(FILES Point2.h Triangle2.h TaVeIt.h Vis2.h FD_2D.h common.h tools.h Circle2.h Segment2.h Color.h Label.h Bbox2.h
	DESTINATION include/gm
        PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
	)
</code></pre>
<p>Danke, lg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/285337/shared-lib-und-testapplikation</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 08:54:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/285337.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 Apr 2011 15:03:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Shared Lib und Testapplikation on Mon, 18 Apr 2011 15:03:27 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Es geht um C++ in Zusammenhang mit CMake. Da es eher C++ ist, habe ich dieses<br />
Forum gewählt: Ich compiliere eine eigene Library mit Hilfe von CMake, wobei<br />
in der CMakeLists.txt, das hier verwendet wird:</p>
<p>add_definitions(-O3 -Wextra -Wunused -Wall -ansi -pedantic-errors -frounding-math -g )</p>
<p>Wird nun die Test-Applikation, die diese Library verwendet, mit den gleichen<br />
Optionen compiliert, so funktioniert sie. Verwende ich aber für die Applikation</p>
<p>add_definitions(-O3 -Wextra -Wunused -Wall -ansi -pedantic-errors -frounding-math -DNDEBUG )</p>
<p>so gibt es Segfaults, und das hängt sicher nicht mit den Assertions zusammen.<br />
Mir scheint, daß der Code dann inkompatibel wird. Kann es sein, daß ich da<br />
noch Compiler-/Linkerflags wie -fPIC oder andere benötige?</p>
<p>Hier folgt die gesamte CMakeLists.txt für die Library. Jeder Hinweis wird<br />
dankend angenommen. Ich starte gerade erst mit CMake.</p>
<pre><code>cmake_minimum_required(VERSION 2.6)

# Name of the project 
project(FD_2D)

set(CMAKE_VERBOSE_MAKEFILE ON)

# Find boost
FIND_PACKAGE( Boost COMPONENTS program_options filesystem system REQUIRED )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )

add_definitions(-O3 -Wextra -Wunused -Wall -ansi -pedantic-errors -frounding-math -g )

set(LIB_SRC HCube2.cpp FD_2D.cpp Circle2.cpp Label.cpp Segment2.cpp ExactTest.cpp tools.cpp Color.cpp Dt2.cpp Vis2.cpp )
add_library(fd2d SHARED ${LIB_SRC})

TARGET_LINK_LIBRARIES( dt2 ${Boost_LIBRARIES} )

# install library
INSTALL( TARGETS fd2d DESTINATION lib PERMISSIONS
	OWNER_READ OWNER_WRITE OWNER_EXECUTE
	GROUP_READ GROUP_EXECUTE
	WORLD_READ WORLD_EXECUTE 
	)

# install headers
INSTALL(FILES Point2.h Triangle2.h TaVeIt.h Vis2.h FD_2D.h common.h tools.h Circle2.h Segment2.h Color.h Label.h Bbox2.h
	DESTINATION include/gm
        PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
	)
</code></pre>
<p>Danke, lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2051187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2051187</guid><dc:creator><![CDATA[libApp]]></dc:creator><pubDate>Mon, 18 Apr 2011 15:03:27 GMT</pubDate></item><item><title><![CDATA[Reply to Shared Lib und Testapplikation on Mon, 18 Apr 2011 15:27:44 GMT]]></title><description><![CDATA[<p>NDEBUG steuert nicht nur Assertions. Ggf. hast du Header in der Lib, die mit NDEBUG ein anderes binäres Layout erzeugen, z.B. durch irgendwelche #ifdefs. Oder der Compiler macht das von sich aus, weil er mit NDEBUG anders arbeitet. Du müsstest von der Lib dann debug und release-Versionen haben, und je nach NDEBUG gegen die passende linken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2051206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2051206</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 18 Apr 2011 15:27:44 GMT</pubDate></item><item><title><![CDATA[Reply to Shared Lib und Testapplikation on Tue, 19 Apr 2011 06:50:10 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>NDEBUG steuert nicht nur Assertions. Ggf. hast du Header in der Lib, die mit NDEBUG ein anderes binäres Layout erzeugen, z.B. durch irgendwelche #ifdefs. Oder der Compiler macht das von sich aus, weil er mit NDEBUG anders arbeitet. Du müsstest von der Lib dann debug und release-Versionen haben, und je nach NDEBUG gegen die passende linken.</p>
</blockquote>
<p>Das war ein Super-Volltreffer, danke! Ich hatte</p>
<pre><code class="language-cpp">class Triangle
{
...bla
#ifndef NDEBUG
        unsigned debug_triangleLabel;
#endif
...bla
};
</code></pre>
<p>in einem Header. Das hätte ich wohl noch sehr lange gesucht.</p>
<p>Schönen Tag! / lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2051454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2051454</guid><dc:creator><![CDATA[libApp]]></dc:creator><pubDate>Tue, 19 Apr 2011 06:50:10 GMT</pubDate></item></channel></rss>