我有一些舊的C代碼,我想結合一些C++代碼。iostream鏈接器錯誤
曾經有過的C代碼如下包括:
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "mysql.h"
現在我要把它用C++使用的iostream這樣的:
#include <windows.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include "mysql.h"
但我不斷收到以下鏈接器錯誤,當我編譯時:
[鏈接器錯誤]未定義的引用'std :: string :: size()const'
[連接子錯誤]未定義參考`的std :: string ::運算符[](無符號整型)const的」
[連接子錯誤]未定義參考`的std :: string ::運算符[](無符號INT)常量 '
[連接子錯誤]未定義參考`的std :: string ::運算符[](無符號整型)const的'
[連接子錯誤]未定義參考`的std ::的ios_base ::初始化:: Init()'
[鏈接器錯誤]未定義對`std :: ios_base :: Init ::〜Init()'的引用'
LD返回1退出狀態
我該如何解決這個問題?
編輯:我的編譯器是開發-C++ 4.9.9.2
不會將`-lc`鏈接爲`libc`,它是一個C運行時庫,而不是C++?對於C++,需要使用`-lstdC++`參數到`gcc`(或者僅僅使用`g ++`自動執行)來連接C++標準庫`libstdC++`。如果你不知道怎麼做,不要試圖去幫助,因爲你同樣可以做一個惡作劇。 – SasQ 2012-08-04 04:36:06