2010-09-06 39 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