question

edom18-7200 avatar image
0 Votes"
edom18-7200 asked edom18-7200 commented

I got "cannot open source file" even if I walk thurough a tutorial.

Hi, I'm new to creating Visual Studio project.

I've tried below tutorial. I'm now creating DLL sample. But I got the error I mentioned at title when I try the tutorial.
https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp?view=msvc-160

Firstly, I created a MathLibrary project that is from the tutorial, then I created a client project too. But I got the error on the client project even if I added a include directory reference in a property setting.

mathclient-additional-include-directories-property.png

103613-error-sample.png

Why I got the error?


c++
error-sample.png (31.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JeanineZhang-MSFT avatar image
1 Vote"
JeanineZhang-MSFT answered edom18-7200 commented

Hi,

I suggest you check if the platform is set to x64.

103623-image.png

And I suggest you could select "All Platforms" for the platform and select "All Configurations" for the Configuration when changing the properties.

103691-image.png

Best Regards,

Jeanine



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.





image.png (1.1 KiB)
image.png (2.8 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for the answer! I solved my problem. You're right.

I added the directory only x86 platform. I added it to All Platforms, then the error has gone.

0 Votes 0 ·
RLWA32-6355 avatar image
1 Vote"
RLWA32-6355 answered SimpleSamples commented

You say that you added the path to the dll header files in the project properties for additional include directories. However, you don't show the entry you made and we do not know the correct paths for the dll headers relative to the file system location of the client project.

So, my best guess is that you entered the wrong path in the project property for additional include directories. If you provide more information we may be able to suggest a specific solution for you.

· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for the rapidly response.

I attached two screenshots. First one is my setting, second one is my location of the header file.

What's wrong of my doing?

103651-my-setting.png


103615-my-location.png


0 Votes 0 ·
my-setting.png (53.0 KiB)
my-location.png (102.4 KiB)

I followed the tutorial to create the MathLibrary DLL project and the MathClient Console App project. After following the instructions in the tutorial both projects built successfully and the MathClient was able to use the MathLibrary dynamic link library.

One thing I noticed in your posted images was that the file system paths did not contain a backslash as the separator but used a different character. I don't know if this makes a difference to Visual Studio.

My project property for the Additional Include Directories looked like this -
103654-include.png


0 Votes 0 ·
include.png (39.4 KiB)

Backslash you mentioned is a Japanese problem because Japanese character set uses backslash code as a "Yen" mark. It's not problem, please ignore.

It seems like the same my include setting. Umm.. why did your project work correctly?

0 Votes 0 ·
Show more comments

And the #include "MathLibrary.h" has Red squiggles under the #include indicating it cannot find the file.

0 Votes 0 ·

Thank you for the reply.

I added a directory to the additional include directory setting but I still got the error. I don't know what was wrong.

0 Votes 0 ·

Do the Red squiggles under the #include go away? If VS can find it then the compiler should be able too. If VS can find it then you can right-click on the file in the #include and be able to select an item for viewing the #include. If you still get the Red squiggles then you still do not have the correct directory specified correctly.

0 Votes 0 ·