मैं linux ubuntu में साधारण प्रोग्राम लिखा था, जब मैं का उपयोग जी ++ कोई त्रुटि है लेकिन जब मैं जीसीसी का उपयोग मैं यह त्रुटि दिखाई:"cmath: ऐसी कोई फ़ाइल या निर्देशिका" जब जीसीसी
test.c:1:17: fatal error: cmath: No such file or directory #include <cmath>
नोट: "वास्तव में मुझे पैकेज को संकलित करने में यह त्रुटि दिखाई देती है, मैंने सोचा कि यह जीसीसी लाइब्रेरी से संबंधित हो सकता है जो लिनक्स पर्यावरण पर सेट नहीं है, इसलिए मैंने त्रुटि को स्पष्ट रूप से निर्धारित करने के लिए सरल कार्यक्रम लिखा था और whitout निर्भरता! " इसलिए कार्यक्रम को जीसीसी के साथ संकलित करना चाहिए ताकि मैं मुख्य समस्या आ सकूं। मैं khow कि मैं cmath के बजाय math.h का उपयोग कर सकते हैं, लेकिन packege cmath का उपयोग किया!
/*test.c*/
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
double sinx = sin(3.14/3);
cout<< "sinx= " << sinx;
return 0;
}
यहाँ है cmath pathes: इस सरल कार्यक्रम है
[email protected]:/# find -name cmath
./opt/root5.32.00/cint/cint/include/cmath
./app/gcc/4.8.0/include/c++/4.8.0/ext/cmath
./app/gcc/4.8.0/include/c++/4.8.0/cmath
./app/gcc/4.8.0/include/c++/4.8.0/tr1/cmath
./usr/include/boost/compatibility/cpp_c_headers/cmath
./usr/include/boost/tr1/tr1/cmath
./usr/include/c++/4.5/cmath
./usr/include/c++/4.5/tr1_impl/cmath
./usr/include/c++/4.5/tr1/cmath
./usr/include/c++/4.6/cmath
./usr/include/c++/4.6/tr1/cmath
./usr/share/gccxml-0.9/GCC/2.95/cmath
./gcc-build/gcc-4.8.0/stage1-i686-pc-linux-gnu/libstdc++-v3/include/ext/cmath
./gcc-build/gcc-4.8.0/stage1-i686-pc-linux-gnu/libstdc++-v3/include/cmath
./gcc-build/gcc-4.8.0/stage1-i686-pc-linux-gnu/libstdc++-v3/include/tr1/cmath
./gcc-build/gcc-4.8.0/i686-pc-linux-gnu/libstdc++-v3/include/ext/cmath
./gcc-build/gcc-4.8.0/i686-pc-linux-gnu/libstdc++-v3/include/cmath
./gcc-build/gcc-4.8.0/i686-pc-linux-gnu/libstdc++-v3/include/tr1/cmath
./gcc-build/gcc-4.8.0/libstdc++-v3/include/ext/cmath
./gcc-build/gcc-4.8.0/libstdc++-v3/include/c/cmath
./gcc-build/gcc-4.8.0/libstdc++-v3/include/c_global/cmath
./gcc-build/gcc-4.8.0/libstdc++-v3/include/c_std/cmath
./gcc-build/gcc-4.8.0/libstdc++-v3/include/tr1/cmath
./gcc-build/gcc-4.8.0/libstdc++-v3/testsuite/26_numerics/headers/cmath
./gcc-build/gcc-4.8.0/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath
./gcc-build/gcc-4.8.0/prev-i686-pc-linux-gnu/libstdc++-v3/include/ext/cmath
./gcc-build/gcc-4.8.0/prev-i686-pc-linux-gnu/libstdc++-v3/include/cmath
./gcc-build/gcc-4.8.0/prev-i686-pc-linux-gnu/libstdc++-v3/include/tr1/cmath
और स्थापित करने के बाद जीसीसी-4.8 मैं इस अनुदेश किया:
[email protected]:~/Desktop# update-alternatives --install /usr/bin/gcc gcc /app/gcc/4.8.0/bin/gcc 40 --slave /usr/bin/g++ g++ /app/gcc/4.8.0/bin/g++
[email protected]:~/Desktop#update-alternatives --install /usr/bin/gcc gcc /app/gcc/4.8.0/bin/gcc 60 --slave /usr/bin/g++ g++ /app/gcc/4.8.0/bin/g++
[email protected]:~/Desktop# update-alternatives --config gcc
बनाने के लिए जीसीसी-4.8 मेरी डिफ़ॉल्ट जीसीसी।
अब
[email protected]:~/Desktop# gcc --version
gcc (GCC) 4.8.0
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
तथ्य की बात के रूप में मैं https://askubuntu.com/questions/309195/cmath-no-such-file-or-directory-include-cmath
में मुख्य समस्या यह लिखा था कृपया मेरी मदद
मैं नहीं जानता कि क्या करना है।
धन्यवाद
+1 अच्छे प्रश्न के लिए और त्रुटि को स्पष्ट रूप से निर्धारित करने के लिए कोड को सरल बनाना। – Abhineet
cmath सी ++ के लिए है, सी के लिए math.h का उपयोग करें, अगर फ़ाइल .c के साथ समाप्त हो जाती है लेकिन यह स्पष्ट रूप से और C++ फ़ाइल है, तो अंत को बदलें। – stdcall