简体   繁体   中英

Why can't Visual Studio find my main function once I add an hlsl/fx file?

Sidenode: I'm not asking anyone to help me with a directx tutorial. I think this error is a normal Visual Studio win32 API error.

Hey guys and girls, I'm trying to learn some DirectX 11 for fun and I found those directx11 examples on github. Now I'm trying to understand each function and see how everything works together. I created a new VS project just to play around with stuff. I copy-pasted all of the code in Tutorial02.cpp into my own project, created a new filter called "Shaders" and changed the properties of my VS solution. At that point I don't have any problems to compile my code. Once I add the Tutorial02.fx, Tutorial02_VS.hlsl and Tutorial02_PS.hlsl to the solution VS can't compile and gives me the following error code:

X3501   'main': entrypoint not found    Project00   C:\Users\Meow\Desktop\directx-tests\Project00\Project00\Project00\FXC   1   

Github link (directx11 tutorial main file): https://github.com/walbourn/directx-sdk-samples/blob/master/Direct3D11Tutorials/Tutorial02/Tutorial02.cpp

What I did:

  1. I created a new VS project called Project00 in my directx-tests folder
  2. I created a new file called Source.cpp
  3. I copy-pasted everything from Tutorial02.ccp (github) into my Source.cpp
  4. I added the resource.h file to my project
  5. I added under "Project00 -> Properties -> Linker -> Input" the same libs as the tutorial
d3d11.lib
d3dcompiler.lib
dxguid.lib
winmm.lib
comctl32.lib
  1. I changed under "Properties -> Link -> System" the SubSystem to Windows(:SUBSYSTEM/WINDOWS)
  2. I copy-pasted the .hlsl and .fx file/s into my project directory (didn't add it to the VS solution yet) At that point it works just fine. It compiles without a problem.

But when I add the Tutorial02.fx, Tutorial02_VS.hlsl and Tutorial02_PS.hlsl to my Shader filter or any other filter and recompile visual studio tells me: 'main': entrypoint not found -- Once I remove (not delete) the files again it works just fine.

Does anyone know why?

(In the tutorial solution they add these files to the solution aswell and it works just fine)

With the help of github demo, I can reproduce this problem. You can refer to the screenshots below to modify:

Tutorial02.fx properties:

在此处输入图片说明

Tutorial02_PS.hlsl properties:

在此处输入图片说明

Tutorial02_VS.hlsl properties:

在此处输入图片说明

You can also refer HLSL Property Pages to learn how individual HLSL shader files are built.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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