Error lnk2001 unresolved external symbol

Error lnk2001 unresolved external symbol

Причина следующая: Вы забыли подключить к проекту необходимые библиотеки (*.lib файлы).

В Visual C++ это делается в Project->Settings, вкладка Link.

error LNK2001: unresolved external symbol _Direct3DCreate8@4
необходимо подключить d3d8.lib

error LNK2001: unresolved external symbol _D3DX.
необходимо подключить d3dx8.lib

error LNK2001: unresolved external symbol _Direct3DCreate9@4
необходимо подключить d3d9.lib

error LNK2001: unresolved external symbol _D3DX.
необходимо подключить d3dx9.lib

error LNK2001: unresolved external symbol __imp__gl.
error LNK2001: unresolved external symbol __imp__wgl.
необходимо подключить opengl32.lib

error LNK2001: unresolved external symbol _glul.
необходимо подключить glu32.lib

Но проще всего подключить их при помощи макроса (для Microsoft Visual Studio всех версий):

Say I have this function called DoThis(const char *abc) in a file called one.cpp. So when I attempt to call this function from another function in a different source file (two.cpp), I get the error: error LNK2001: unresolved external symbol (C++), even though I used #include "one.h" What would I do to fix this?

2 Answers 2

That means that the definition of your function is not present in your program. You forgot to add that one.cpp to your program.

What "to add" means in this case depends on your build environment and its terminology. In MSVC (since you are apparently use MSVC) you’d have to add one.cpp to the project.

In more practical terms, applicable to all typical build methodologies, when you link you program, the object file created form one.cpp is missing.

Sounds like you are using Microsoft Visual C++. If that is the case, then the most possibility is that you don’t compile your two.cpp with one.cpp (one.cpp is the implementation for one.h).

Читайте также:  Qt графики в реальном времени

If you are from command line (cmd.exe), then try this first: cl -o two.exe one.cpp two.cpp

If you are from IDE, right click on the project name from Solution Explore. Then choose Add, Existing Item. Add one.cpp into your project.

Not the answer you’re looking for? Browse other questions tagged c++ or ask your own question.



Hot Network Questions

site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2020.1.13.35763

Please help. On Visual Studio 2008, I’m getting the following errors.

Here is the situation. — DiskTest.exe is one of 3 projects in my solution — This project builds perfectly for Debug x64, Release x64, and Debug Win32. Release Win32 is the only one generating these errors. — I have spend hours comparing the properties pages for all 4 config/machine combinations, and am confident that no properties are missing from one version to the next. I paid special attention to "Additional dependencies", "Additional Librari Directories", "Input", etc. Ofcourse, paths to .lib files point to either Debug or Release, and x86 or x64 for the respective config or platform.

The only "additional dependency" this project has is SBF_Util.lib and SBF_Utild.lib for Debug. I made sure that all 4 versions (debug win32 and x64, and Release win32 and x64) of this library exist in the folder specified in each "additional library directory" I also checked dumpbin on each version of the library to make sure the platform matches.

I have seen other situations where a main entry point is missing, but in this case, all other versions build with no problems, it is only on Win32 Relase version that generates this error, so I don’t think I need to change anything in the code.

Читайте также:  Evga nforce 680i sli

Can anybody provide any clues?, I’m out of ideas. Any ideas will be very much appreciated. Thanks.

Ссылка на основную публикацию
Eax 1300 pro 256 mb
ATI, наконец, выпустила на рынок новое поколение видеокарт. Новое семейство содержит три новых видеочипа: R520, RV530 и RV515. Нетрудно догадаться,...
Cpu amd fx 8300
Описание AMD начала продажи AMD FX-8300 в октябре 2012. Это десктопный процессор на архитектуре Vishera, в первую очередь рассчитанный на...
Cpu hash что это
AIDA64 имеет множество тестов, которые возможно применять для оценивания состояния разных составляющих компьютера или техники в целом. Это искусственные тесты,...
Ebay как отправить товар из россии
Вопросов, связанных с торговлей на площадке eBay у жителей России возникает бесконечное множество. Особенно в нынешних экономических реалиях, когда продажи...
Adblock detector