I have a C project that i am able to compile and run successfully, however when i add another include like #include <vector> even without actually using the vector type i am getting the following annoying errors:
1>c:\program files (x86)\microsoft visual studio11.0\vc\include\wchar.h : error C4335: Mac file format detected: please convert the source file to either DOS or UNIX format
and around 30 more errors related to the same wchar.h file.
I have search for a solution and i have done the suggestion to save my project files with the windows end-of-line but that didn't help.
My goal in including the vector lib is to uses vectors in my current project.
EDIT:
I tried to open the wchar.h file using text editor but all i get is a blob of data nothing like an header file, maybe it is corrupted somehow?
Thanks.
Or open wchar.h in Notepad++ -> Edit -> EOL Conversion -> Windows format.
Here you can get Notepad++: http://notepad-plus-plus.org/
If you don't have it, get it. It is a must have application on every programmers PC.
After repairing the VS 2012 install it works as it should, i assume that the wchar.h file got corrupted.
The file wchar.h is not in the right encoding, probably it is Unicode or UTF8.
Open wchar.h from visual studio, select all and copy, create a new h file and past and save to replace the exsiting wchar.h
Related
I am a C# developer, and spoiled rotten when it comes to references and dependencies. I am working on a small project now in Visual C++ (Visuial Studio 2017), where I want to use the libtomcrypt and libtommath libraries. I've created a small project and added the 2 projects to my solution:
I have also added my includes:
And I added the dependencies:
However, I still can't build:
Error C1083 Cannot open include file: 'tomcrypt.h': No such file or directory
I am not sure what else I need to do to get the references working and the code to compile. Any pointers is appreciated!
The error message indicates that the compiler can't find the file tomcrypt.h while compiling one of your source files. From the message I would guess that you have a line like the following in your source file:
#include <tomcrypt.h>
(...or perhaps with quotes instead of brackets.) From your screenshot I can see that you've added "...\repos\libtomcrypt-develop\src\headers" to your include path. Is the file tomcrypt.h found directly in that folder, or is it perhaps in a subfolder instead?
Your #include directive will basically append whatever path you give it to each entry in your include path when looking for the file, so if there are subfolders in between, you'll have to expand your #include directive to include those folders.
If this doesn't solve your problem, perhaps try posting the actual full path of where this header file exists on your filesystem, as well as your complete include path value! (The full compiler command from the build log would be useful, as well as the complete error message(s) related to this source file.)
Edit:
The original poster posted a separate answer indicating that the actual problem was that the Visual Studio Project Properties were set correctly, but that he was accidentally trying to build a different Configuration. :(
I was building the project under x86. Once I changed it to x64, it built just fine.
I have a decent understanding of C#. I've been asked to make a SDK along with our program so that a customer can make his own UI using our functions. In C#, I did this by adding a DLL. I had to use a database file (.db) to hold commands, and it went successfully. Now I've been asked to do the same in C++. I'm very new to C++. But here's what I read from MSDN and did:
I created a library project.
Added database as a resource file, sqlite3 header file and library file(I got from giving lib command on command prompt).
Created a header file with functions and wrote in a .cpp file with all function definitions.
Built it and got the library file from lib command.
So far, so good. Now when I try to use this library file and header, I'm getting the following errors during build time.
error C2059: syntax error : '<'
error C2018: unknown character '0x7'
error C2018: unknown character '0x60'
error C2018: unknown character '0x7'
error C2018: unknown character '0x2'
error C2018: unknown character '0x1e'
error C2018: unknown character '0x18'
I struggled with this for sometime when I remembered that these errors were the same I got a few days ago. I actually asked the question in SE and got the answer (Error while including database file in C++ project).
So I inferred that the compiler is trying to read the database file saved in the library file and hence I got these errors.
Now I have three questions:
Am I right? Is the compiler trying to read the .db file stored in .lib file?
If so, can anyone please give any suggestions
Also, if you think I'm wrong, I would appreciate any other explanations.
I'm using Visual Express C++ 2010. I used command prompt that comes with Visual Studio to create .lib file. My reference for creating .lib file was https://msdn.microsoft.com/en-us/library/ms235627.aspx#BKMK_CreateAppToRefTheLib.
A database file cannot be stored in a static library file to be deployed. Because the compiler ALWAYS reads through the contents of the library. It shows that its reading this when you are building the program.
So what to do if you have to issue a database with your SDK? I have two solutions:
Add database file with your .lib file and .h file and just flat out give a glossary of commands with the SDK. (I however do not advise this)
Change the extension of database file and write methods in .lib file calling database using sqlite3 functions. Give the user a glossary of functions that you wrote with function names masked so that they dont know its a database file in play. The database file need not have .db extension for sqlite to recognize it. Just give sqlite_open and include database name as database.bhjbkhj (where bhjbkhj is a random extension you wrote). Sqlite is very good in this regard at recognising databases.
So there you go. Problem cannot be solved. But two alternatives.
I'm working with an API which has #defineed all their include files. I'm developing in Visual C++ 2010 Express, and it's been working fine up till now.
I was adding a new cpp-file to the project, and accidentally added a "Windows Form" instead. VC warned me that my project was not using CLR at the moment, did I really want to? I clicked no, and added the file as intended. After that, however, my project no longer compiles.
The code looks basically like this:
api_header.h:
#define DEFINED_HEADER_NAME "path/to/header/file.h"
stdhpf.h:
#include DEFINED_HEADER_NAME
As I said, worked fine for a long time. Now I get this:
error C2006: '#include' : expected a filename, found 'identifier'
fatal error C1083: Cannot open include file: '': No such file or directory
What is causing this? I found some post that said it was because of having turned on precompiled headers, but I checked Project properties > Configuration properties > C/C++ / Precompiled headers, and it's off (I mention the setting path since I'm new to VS, there might be more than one way to do it...).
Any ideas?
The problem almost certainly lies in the order in which the two statements are pre-processed, rather than having anything to do with inadvertently adding a Windows Form object.
This knowledge base article suggests:
The problem is in using a defined constant to specify an include file in the #include directive. The directive is being processed before the macro is completely expanded, resulting in the error.
The second error seems to confirm this, as it indicates the pre-processor is searching for an include file with an empty name:
fatal error C1083: Cannot open include file: '': No such file or directory
The order of your include files has changed. Perhaps Visual Studio inserted a #include "stdhpf.h" somewhere ahead of your #include "api_header.h".
Disable precompiled headers. It should helps.
I am new to visual studio.I have created a simple console application and then selected an empty project of c++.
I have pasted the code form
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
it is giving the following error
error C1083: Cannot open include file: 'stdafx.h': No such file or directory.
Can any body help me how ti solve that issue.
Also i have pasted the code from
http://www.cprogramming.com/tutorial/opengl_windows_programming.html
and it gives me error in MessageBox function.
Fall in the pit of success by using an appropriate project template. Which is Win32 + Win32 Project, don't tick the "Empty project" option on the property page. You'll get pre-generated code for a Win32 application, take a look at it since you might want to keep parts of it. Or just delete it all past the #include for stdafx.h and replace it with the code you want to try. The stdafx.h file is already pre-cooked for you.
The second snippet probably fails to compile because the code sample is not using Unicode strings. Put an L in front of the string literal, like L"\tHello world".
"stdafx.h" is the default name for the precompiled header in Visual Studio.
If you are not using precompiled headers you can omit that include directive.
See this article on Wikipedia for an explanation of precompiled headers.
I'm trying to integrate two projects, and to that end am including header files from one into the other. I'm using visual studio 2008 express.
The line
int E4407B_PPM(int &);
is throwing errors in the new project, but the original project compiles just fine.
The error I'm getting:
error C2143: syntax error : missing ')' before '&'
Any ideas?
Edit: I ended up removing the lines that took parameters in by reference, and just insured that all functions were declared before they were used in the actual source file. I guess it was a C++/C thing.
You are probably building the second project (or at least the source file) as straight C. Make sure the file has a .cpp extension or that you are forcing a C++ compile (you can use the /TP compile option to do that).
Edit You can specify it for a single file: Right click on the file in the solution explorer and select Properties. Click on the Advanced option under C/C++. Choose "Compile as C++ Code (/TP)" (second option in the page in my version of Visual Studio).