Visual Studio Compiler Error - c++

I was making a simple DLL as a test in visual studio 2010.
Here is the code for SimpleCPP.cpp
#include iostream
#include "SimpleH.h"
namespace nmspace
{
void myclass::Crap()
{
std::cout << "Test." << std::endl;
}
}
Here is the code for the header file
#include <iostream>
namespace nmspace
{
class myclass
{
public:
static __declspec(dllexport) void Crap();
};
}
My problem is when I compile I get an error that says that visual studio can't find the file SimpleDLLd.dll. In closer inspection I see that when the program is compiling visual studio adds a d to the release files. For example when the DLL is supposed to be SimpleDLL.dll (The project name is SimpleDLL) visual studio adds a d and outputs SimpleDlld.dll. I tried doing the same thing in another project and it did the same thing. I then proceeded to Visual Studio 2013 and copy and pasted the contents of the cpp and header files into new files and surprisingly got the same exact result as Visual Studio 2010. How would I fix this error? Thank you for responding.

Check the name of the build target in your project file settings. The name of the resulting file should be in the
Linker->General->Output File
setting in the project which is usually $(OutDir)$(TargetName)$(TargetExt) by default.

Related

Visual Studio c++ no symbols loaded for dll after moving dll into proper code path

I am trying to create a simple application in Visual Studio 2019 that connects to SQL Server. I am using the sqlapi++ library to create the connection. I am trying to gain more experience with c++ and 3rd party libraries. My experience in c++ has mostly been on a macbook with xcode and standard c++ libraries.
I get the following error:
then I get this error:
No symbol loaded for sqlapi.dll
binary was not built in with debug information.
It specifies the file location as C:\Users\name\source\repos\ProjectName\Debug\sqlapi.dll. I look in this file location and it is there. Which is also where the exe file gets generated. My code so far is very simple:
#include <SQLAPI.h>
#include <iostream>
int main()
{
SAConnection con;
SACommand cmd(&con);
try
{
con.Connect(
"Database#ServerName",
"Username",
"Password",
"SA_SQLServer_Client);
cmd.setCommandText("SELECT * FROM dbo.TableName");
cmd.Execute();
}
catch (int exception)
{
}
}
I set a breakpoint on con.Connect() and continue, then it loads symbols for a few seconds before giving me an error. My question is, how can I ensure that my .dll files get loaded in Visual Studio properly? Should my .dll and .pdb files all be moved to the file location that the .exe files gets generated in? Or just put them in the same file as the .cpp file?

cannot open include file 'Graphics.hpp' no such file or directory ,additional include for visual studio not working

i m trying to use sfml in my project using visual studio 2019. Following sfml documentation to perform setup for visual studio i have performed all the action required
i have included include folder in c/c++/additional include directory and also provided path for lib folder in linker setting and also provided additional dependencies in linker/input
but
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
std::cout << "i cant tolerate" << std::endl;
return 0;
}
this code shows above mentioned error ,
cannot open include file 'Graphics.hpp' no such file or directory
it seems like include path is not working
how can i solve this issue
i tried many times but got same result
if anyone facing the same problem please check the platform in the project/properties win32 worked for my particular problem

function cannot access 'xxx::xxx::operator <<'

I have some code like:
namespace xxx {
namespace xxx {
struct local {
static void xxxxx(....) {
std::cout << "prints..........." <<std::endl;
}
}
}}
And I get errors as the title stated: "function cannot access 'xxx::xxx::operator <<'"
I created the MSVC project with visual studio 2005. While when I open the project in visual studio 2010, everyting works fine. But I need it working visual studio 2005, what might be the reason for it?
When I open it from Visual Studio 2010, I didn't change anything, it works directly.
And I know it is working with gcc as well. So something I can do for the msvc project to make it working without changing the code?

fatal error C1083: Cannot open include file: 'iostream': No such file or directory

I've reinstalled Visual Studio 2010 Professional several times to try to get it to work.
I had to uninstall Visual Studio 2012 Professional because it wasn't compiling something we did in class.
I completely uninstalled everything including SQL Server..
I went to VC/include and the iostream header file is not there.
#include <iostream>
int main () {
cout << "hello";
system ("PAUSE");
return 0;
}
This is all I'm trying to do because nothing else is working.
It's really driving me crazy because I need to get it working so that I can do my project!!!
Every time I do; new project => empty project => add an item to source =>.cpp
I'm running windows 8.
It just says Error cannot open source file
Also, error cout identifier is undefined....
I'm wondering if I should do a system restore?
Or if I should just completely reinstall windows 8 from my recovery media?
One problem is that you did not include the namespace std.
This is what your code should look like:
#include <iostream>
using namespace std;
int main (void) {
cout << "hello" << endl;
system("pause");
return 0;
}
or you could have done something like this: std::cout << "Hello" << std::endl;
This may be a problem because you did not set your environment to C++. This is how you do it:
Go to Tools > Import and Export settings. If you cannot find it, just search for it in Quick Search
Then go to reset all settings.
Then simply select "Visual C++"
Restart.
That should do the trick. If it does not, you might consider re-installing Visual C++ itself. For VS 2012. If that does not work, then re-install the program.
if it is problem with visual studio 2012, install this update.

Building a C++ project in Visual Studio doesn't create any files

I recently decided to start learning Visual Studio so that it replaces my need for CodeBlocks and MinGW for C++ programming.
So, today I made a new Win32 C++ Console Application, wrote down this code in a new .cpp file
#include <iostream>
using namespace std;
int main()
{
int a;
cin >> a;
cout << a << endl;
return 0;
}
and compiled it. The log said
1>------ Build started: Project: CPP_CONSOLE_TEST, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(357,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
and I though my code was compiled and my .exe was created.
Then, upon trying to debug my program, Visual Studio said:
Unable to start program 'C:\Users\XYZ\Documents\Visual Studio 2013\Projects\CPP_CONSOLE_TEST\Debug\CPP_CONSOLE_TEST.exe'. The system cannot find the file specified.
I then opened the Debug folder of the project and it was completely empty...
I've been searching around Google for some time and I even tried to "Repair" my Visual Studio build with no results. Any help?
Quick edit: Just tried compiling a C# app, just to see if the IDE itself was the problem. It compiled and ran just fine, so it's some issue with the Visual C++ compiler and its settings...
Turns out I hadn't added the source file to the Project... :|
Visual Studio, has its own vision of c++ projects. By default, it needs a #include "stdafx.h" on top of your cpp file, with the associated stdafx.h and stdafx.cpp files.
Then, in a c++ visual studio project, the real definition of the main function is int _tmain(int argc, _TCHAR* argv[]). But it should work with your definition.
Why don't you try to use Serge Rogatch's solution?
There is a bug in Visual Studio which leads to problems when project has long path.