2010-09-06 58 views
-3

我可以在linux C++編譯器或visual C++ 2010中使用符號C++功能嗎?還一個問題,有時在節目有這樣的頭部代碼gcc或microsoft visual C++中的符號C++

#include <iostream> 
#include "symbolicc++.h" 
using namespace std; 

int main(void) 
{ 
Symbolic x("x"); 
cout << integrate(x+1, x);  // => 1/2*x^(2)+x 
Symbolic y("y"); 
cout << df(y, x);    // => 0 
cout << df(y[x], x);   // => df(y[x],x) 
cout << df(exp(cos(y[x])), x); // => -sin(y[x])*df(y[x],x)*e^cos(y[x]) 
return 0; 
} 

#include "symbolicc++.h"我曾嘗試

#include " ",但它不告訴我symbolicC++。h後,該怎麼辦呢,請給我幾個例子

there is such error after compile 
symbolic.cpp:2:25: error: symbolicc++.h: No such file or directory 
symbolic.cpp: In function ‘int main()’: 
symbolic.cpp:7: error: ‘Symbolic’ was not declared in this scope 
symbolic.cpp:7: error: expected ‘;’ before ‘x’ 
symbolic.cpp:8: error: ‘x’ was not declared in this scope 
symbolic.cpp:8: error: ‘integrate’ was not declared in this scope 
symbolic.cpp:9: error: expected ‘;’ before ‘y’ 
symbolic.cpp:10: error: ‘y’ was not declared in this scope 
symbolic.cpp:10: error: ‘df’ was not declared in this scope 
symbolic.cpp:12: error: ‘cos’ was not declared in this scope 
symbolic.cpp:12: error: ‘exp’ was not declared in this scope 
+0

-1。谷歌+我很幸運能給你實際的答案(這是對的,只要你正確安裝) – 2010-09-06 14:18:46

+0

@Alexandre你認爲爲什麼在這裏發帖?因爲我已經搜索和不理解所以問人們爲什麼downvote?好吧 – user439547 2010-09-06 14:22:56

+0

我可以't downvote,否則我會減少你的標記減少我的標記 – user439547 2010-09-06 14:23:51

回答

2

轉到http://issc.uj.ac.za/symbolic/symbolic.html,下載eg SymbolicC++ 3 3.34壓縮的tar文件。

解壓該tar.gz文件,並調整您的編譯器/ IDE以在頭文件/子目錄中搜索其他頭文件。

例如使用命令行Linux上:

[[email protected] ~]$ wget http://issc.uj.ac.za/symbolic/sources/SymbolicC++3-3.34.tar.gz 
16:20:24 (109.71 KB/s) - `SymbolicC++3-3.34.tar.gz' saved [155572/155572] 
[[email protected] ~]$ mkdir symbolicc++ 
[[email protected] ~]$ cd symbolicc++/ && tar -xvzf ../SymbolicC++3-3.34.tar.gz ; cd .. 
[[email protected] ~]$ gcc -Wall -I/home/nos/symbolicc++/headers -o myprogram myprogram.cpp 
0

一些澄清,以極其號有用的答案 - 你必須改變GCC到G ++編譯器,GNU編譯器的新版本。這裏是簡單的GNU Makefile,編譯example/lagrange.cpp示例:

PROGRAM=legendre.cpp #program to compile 
LIB=../headers #localization of headers of symbolicc++ library, specifically symbolicc++.h file 

run: 
    g++ -I$(LIB) -o main.x $(PROGRAM) 
    (time ./main.x) 

clean: main.x 
    -rm main.x