简体   繁体   English

如何使用Visual Studio在C中引用/包括外部源文件/库?

[英]How to reference/including external source files/libraries in C with Visual Studio?

Trying to create a C project that references this so that I could use it in my own application. 尝试创建一个引用项目的C项目,以便可以在自己的应用程序中使用它。 Unfortunately I'm having a bit of trouble. 不幸的是我有点麻烦。 I'm a C# programmer and in that language it is very simple. 我是C#程序员,用这种语言非常简单。 First you reference the library and then you use the using keyword. 首先,您引用库,然后使用using关键字。

However, considering I have never programmed in C before I'm having a bit of trouble with this simple task. 但是,考虑到我从来没有用C编程过,在我对这个简单的任务有点麻烦之前。 I tried just copy and pasting all the source files in to my project directory where my main class was also stored but it still couldn't be found. 我尝试仅将所有源文件复制并粘贴到我的主目录也存储在我的项目目录中,但仍然找不到。 I also tried including the compiled DLL but got the same error: 我也尝试过包含已编译的DLL,但出现了相同的错误:

error C1083: Cannot open include file: 'mpir.h': No such file or directory

I'm reading the documentation for it and it says to only do this at the top of your source file: 我正在阅读它的文档,它说只能在源文件的顶部执行此操作:

#include <mpir.h>

Which is what I'm doing but it does not seem to be working.. Any suggestions? 我在做什么,但似乎没有用。有什么建议吗?

If mpir.h is in the same directory as your source file, you need to use the include directive with quotations instead of brackets, like this: 如果mpir.h与源文件位于同一目录中,则需要使用带有引号而不是方括号的include指令,如下所示:

#include "mpir.h"

Take a look at Wikipedia's description of including files . 看一下Wikipedia对包含文件的描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM