Kg到磅转换器构建误差(CLion) [英] Kg to pounds converter build error (CLion)

查看:276
本文介绍了Kg到磅转换器构建误差(CLion)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习C ++编程语言,通过阅读C ++ Primer Plus 5th这本书,但我遇到了一个问题。这本书刚开始详细介绍函数,函数原型,函数头等等。我决定尝试使KG - > Pounds转换器作为练习,但我的问题是,当我尝试构建它(Im使用CLion )我遇到构建错误。

I've just started to learn the C++ programming language by reading the book "C++ Primer Plus 5th addition" but I'm coming across a problem. The book just started to go into detail with functions, function prototypes, function headers and such.I decided to try and make a KG --> Pounds converter as practice, but my problem is that when I try to build it (Im using CLion) I get a build error.

代码:

#include <cmath> // [EDIT] Removed this line as it isnt being used
#include <iostream>
using namespace std;

double pounds_converter(double);
int main()
{
    cout << "Welcome to the kg to pounds convertor" << endl;
    cout << "Enter the desired kg's to change to pounds: ";
    double my_kg;
    cin >> my_kg;
    double pounds = pounds_converter(my_kg);
    cout << my_kg << " in pounds is: " << pounds << endl;
    cin.get();
    return 0;
}

double pounds_converter(double n)
{
    return 2.2046226218 * n;

}

First Build错误:

First Build error:

"C:\Program Files (x86)\JetBrains\CLion 1.0.3\bin\cmake\bin\cmake.exe"
--build C:\Users\Admin\.clion10\system\cmake\generated\23677da2\23677da2\Release
--target newproject -- -j 8 Scanning dependencies of target newproject [100%] Building CXX object CMakeFiles/newproject.dir/main.cpp.obj In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cmath:44:0,
                 from C:\Users\Admin\ClionProjects\newproject\main.cpp:1: c:\mingw\include\math.h: In function 'float hypotf(float, float)': c:\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope  { return (float)(_hypot (x, y)); }
                              ^ mingw32-make.exe[3]: *** [CMakeFiles/newproject.dir/main.cpp.obj] Error 1 mingw32-make.exe[2]:
*** [CMakeFiles/newproject.dir/all] Error 2 mingw32-make.exe[1]: *** [CMakeFiles/newproject.dir/rule] Error 2 mingw32-make.exe: *** [newproject] Error 2 CMakeFiles\newproject.dir\build.make:53: recipe for target 'CMakeFiles/newproject.dir/main.cpp.obj' failed CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/newproject.dir/all' failed CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/newproject.dir/rule' failed Makefile:108: recipe for target 'newproject' failed

删除#include cmath行后,因为它不需要或在我的程序中没有使用,我试图再次构建它,但收到一个不同的错误是:

After removing the #include cmath line as it wasn't needed nor being used in my program, I attempted to build it yet again but received a different error which was:

"C:\Program Files (x86)\JetBrains\CLion 1.0.3\bin\cmake\bin\cmake.exe" --build C:\Users\Admin\.clion10\system\cmake\generated\23677da2\23677da2\Release --target newproject -- -j 8
Linking CXX executable newproject.exe
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot open output file newproject.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
CMakeFiles\newproject.dir\build.make:86: recipe for target 'newproject.exe' failed
CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/newproject.dir/all' failed
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/newproject.dir/rule' failed
Makefile:108: recipe for target 'newproject' failed
mingw32-make.exe[3]: *** [newproject.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/newproject.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/newproject.dir/rule] Error 2
mingw32-make.exe: *** [newproject] Error 2


推荐答案

您的mingw设置的问题,因为您的编译器未能找到在 c:\mingw\include\\\\\\\\\\\\\\\\\然而,你实际上不需要你的代码的头。您可以删除 #include 行,它将编译和运行就好了。 (测试它)

There is some sort of problem with your mingw setup, because your compiler is failing to find a function used in the c:\mingw\include\math.h file. However you don't actually need that header for your code. You can remove the line #include and it's going to compile and run just fine. (tested it)

如果你想在其他程序中使用该标题,你需要解决你的mingw设置。

You do need to solve your mingw setup however if you wish to use that header in other programs.

如果你仍然得到一个错误,这很可能是由于你使用的其他标题。重新安装MinGW,检查哪些文件应该包含缺少的功能,并尝试在您的计算机上找到它们。

If you still get an error it would be most likely due to the other header that you have used. Reinstall MinGW, check which files should contain the missing functions and try to find them on your machine.

这篇关于Kg到磅转换器构建误差(CLion)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆