<?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[C Library in C++ Programm verwenden]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein C++ Programm geschrieben in dem ich nun auch ein Problem der linearen Optimierung lösen muss. Dafür möchte ich das GNU Linear Programming Kit (GLPK) verwenden. Dies bietet zwar ein API, aber leider nur für C. Wenn ich das Standardbeispiel mit gcc kompiliere und linke gibt es kein Problem:</p>
<pre><code class="language-cpp">/* sample.c */
// Compile with: gcc sample.c /usr/lib/libglpk.a

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &quot;glpk.h&quot;

int main(void) {
	LPX* lp;
	lp = lpx_create_prob();
	// ...
	return 0;
}
</code></pre>
<p>Wenn ich aber g++ verwende, bekomme ich einen Linkerfehler:</p>
<pre><code>/tmp/cccrUmum.o: In function `main':
sample.c:(.text+0x12): undefined reference to `glp_lpx_create_prob()'
sample.c:(.text+0x28): undefined reference to `glp_lpx_set_prob_name(LPX*, char*)'
sample.c:(.text+0x3b): undefined reference to `glp_lpx_set_obj_dir(LPX*, int)'
collect2: ld returned 1 exit status
</code></pre>
<p>Wie kann ich GLPK trotzdem in meinem C++ Programm verwenden?</p>
<p>Dank Euch!!<br />
Sun</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/194373/c-library-in-c-programm-verwenden</link><generator>RSS for Node</generator><lastBuildDate>Mon, 28 Sep 2026 11:32:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/194373.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Oct 2007 20:08:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C Library in C++ Programm verwenden on Fri, 05 Oct 2007 20:08:29 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein C++ Programm geschrieben in dem ich nun auch ein Problem der linearen Optimierung lösen muss. Dafür möchte ich das GNU Linear Programming Kit (GLPK) verwenden. Dies bietet zwar ein API, aber leider nur für C. Wenn ich das Standardbeispiel mit gcc kompiliere und linke gibt es kein Problem:</p>
<pre><code class="language-cpp">/* sample.c */
// Compile with: gcc sample.c /usr/lib/libglpk.a

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &quot;glpk.h&quot;

int main(void) {
	LPX* lp;
	lp = lpx_create_prob();
	// ...
	return 0;
}
</code></pre>
<p>Wenn ich aber g++ verwende, bekomme ich einen Linkerfehler:</p>
<pre><code>/tmp/cccrUmum.o: In function `main':
sample.c:(.text+0x12): undefined reference to `glp_lpx_create_prob()'
sample.c:(.text+0x28): undefined reference to `glp_lpx_set_prob_name(LPX*, char*)'
sample.c:(.text+0x3b): undefined reference to `glp_lpx_set_obj_dir(LPX*, int)'
collect2: ld returned 1 exit status
</code></pre>
<p>Wie kann ich GLPK trotzdem in meinem C++ Programm verwenden?</p>
<p>Dank Euch!!<br />
Sun</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378860</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378860</guid><dc:creator><![CDATA[Sun85]]></dc:creator><pubDate>Fri, 05 Oct 2007 20:08:29 GMT</pubDate></item><item><title><![CDATA[Reply to C Library in C++ Programm verwenden on Fri, 05 Oct 2007 20:13:30 GMT]]></title><description><![CDATA[<p>Probiers mal mit</p>
<pre><code class="language-cpp">extern &quot;C&quot; {
#include &quot;glpk.h&quot;
}
</code></pre>
<p>Aber eigentlich werden die entsprechenden „Wächter“ heute fast überall von den Entwicklern der Bibliotheken eingebaut.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378862</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Fri, 05 Oct 2007 20:13:30 GMT</pubDate></item><item><title><![CDATA[Reply to C Library in C++ Programm verwenden on Fri, 05 Oct 2007 20:27:13 GMT]]></title><description><![CDATA[<p>hast du auch gegen den glpk gelinkt?<br />
also: g++ main.c -lglpk</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378868</guid><dc:creator><![CDATA[ghorst]]></dc:creator><pubDate>Fri, 05 Oct 2007 20:27:13 GMT</pubDate></item><item><title><![CDATA[Reply to C Library in C++ Programm verwenden on Fri, 05 Oct 2007 20:32:32 GMT]]></title><description><![CDATA[<p>ghorst schrieb:</p>
<blockquote>
<p>hast du auch gegen den glpk gelinkt?<br />
also: g++ main.c -lglpk</p>
</blockquote>
<p>Dann hätte die Fehlermeldung von _glp_lpx_set_obj_dir gesprochen, ohne Parametertypen oder solches Zeugs (da C-Funktionen diese nicht haben muss man ja gerade extern &quot;C&quot; schreiben).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378869</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Fri, 05 Oct 2007 20:32:32 GMT</pubDate></item><item><title><![CDATA[Reply to C Library in C++ Programm verwenden on Fri, 05 Oct 2007 20:38:21 GMT]]></title><description><![CDATA[<p>nicht wirklich, da der compiler danke header weiß, was ihm fehlt...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378870</guid><dc:creator><![CDATA[ghorst]]></dc:creator><pubDate>Fri, 05 Oct 2007 20:38:21 GMT</pubDate></item><item><title><![CDATA[Reply to C Library in C++ Programm verwenden on Fri, 05 Oct 2007 20:39:06 GMT]]></title><description><![CDATA[<p>ghorst schrieb:</p>
<blockquote>
<p>nicht wirklich, da der compiler danke header weiß, was ihm fehlt...</p>
</blockquote>
<p>Aber der Linker nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378871</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 05 Oct 2007 20:39:06 GMT</pubDate></item><item><title><![CDATA[Reply to C Library in C++ Programm verwenden on Sat, 06 Oct 2007 10:32:30 GMT]]></title><description><![CDATA[<p>Ja! Mit extern tut's!</p>
<p>Dank Euch ganz herzlich!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1379055</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1379055</guid><dc:creator><![CDATA[Sun85]]></dc:creator><pubDate>Sat, 06 Oct 2007 10:32:30 GMT</pubDate></item></channel></rss>