I must use main() and call a function from windows.h.
The following code wants a WinMain() function to be used instead of main().
#include <windows.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int vk_Shift = 16;
while (1)
{
if (GetAsyncKeyState(vk_Shift) < 0)
{
printf("Shift is pressed\n");
}
}
}
Error
Error 1 error LNK2019: unresolved external symbol _WinMain#16
referenced in function ___tmainCRTStartup
Error 2 error LNK1120: 1 unresolved externals
How can I get this work in VS2013?
Okay, guys, I got it.
Felix Palmen's advice works.
... ... I guess configuring it as "console" application should do the trick.
So, what I did is, I changed my project's preference from WIDOWS to CONSOLE.
Related
I have one problem with library <bcrypt.h>. Compiler say error with function bcrypt_gensalt.
#include <iostream>
#include <bcrypt.h>
using namespace std;
int main() {
const char* passwd = "Secret_Password";
char results[BCRYPT_HASHSIZE];
bcrypt_gensalt(10, results);
system("pause");
return 0;
}
Error from compiler:
unresolved external symbol bcrypt_gensalt referenced in function main
You need to reference Bcrypt.lib.
See here: http://msdn.microsoft.com/en-us/library/ba1z7822.aspx.
I'm trying to run a unix compiler-project written in c with MS Visual-Studio 2013 and I can't get rid of the following error:
error LNK2019: unresolved external symbol "_snprintf" referenced in
function "PUBLIC void SyntaxError( int Expected, TOKEN CurrentToken )"
If I get it right it is a problem where VisualStudio can't find the body/declaration from the snprintf() function, which should be defined in stdio.h.
The project works fine with cygwin. I had to add _CRT_SECURE_NO_WARNINGS to preprocessor settings to get this far, but i don't think that has a influence.
Here is the named function:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "line.h"
#include "strtab.h"
#include "scanner.h"
[..code..]
PUBLIC void SyntaxError( int Expected, TOKEN CurrentToken )
{
char s[M_LINE_WIDTH+2];
snprintf( s, sizeof(s), "Syntax: Expected %s, got %s\n", Tokens[Expected], Tokens[CurrentToken.code] );
Error( s, CurrentToken.pos );
}
If you can help me or there is anything else you need to know please tell me. It's my 3rd day now and I am running out of ideas ;).
So far... Tobias
The name of this function with the MSVC compiler is _snprintf() with an underscore.
I would like to to use DwfToolkit in my app, but I have problem to link it.
The code:
// DWF Core headers
#include "dwfcore/String.h"
#include "dwfcore/Core.h"
#include "dwfcore/SkipList.h"
#include "dwfcore/InputStream.h"
using namespace DWFCore;
// WHIP! headers
#include "whiptk/whip_toolkit.h"
// DWF Toolkit headers
#include "dwf/Version.h"
#include "dwf/Toolkit.h"
#include "dwf/package/Manifest.h"
#include "dwf/package/EPlotSection.h"
#include "dwf/package/EModelSection.h"
using namespace DWFToolkit;
int _tmain(int argc, _TCHAR* argv[])
{
DWFString path("c:\\test.dwf");
DWFFile file(path);
DWFPackageReader reader( file );
return 0;
}
In linker options (Additional Dependencies) I added dwfcore.1.7.0.lib, dwftk_ro.7.7.0.lib, whiptk_ro.7.13.601.lib. After compile:
Error 902 error LNK2019: unresolved external symbol "__declspec(dllimport)
public: __thiscall DWFCore::DWFString::DWFString(wchar_t const *)"
(__imp_??0DWFString#DWFCore##QAE#PB_W#Z) referenced in function _wmain
When I erase line DWFPackageReader reader( file ); from code, program is builded.
If you are linking static lib add dwfcore_static in the preprocessor.
I have a C-Project, which I would like to boost using a CUDA-module. But somehow, the externally defined variables can not be resolved. I am using Microsoft Visual C++ 2010 Express and CUDA Toolkit 5.0.
The following shows my minimal (not) working example:
main.c:
#include "main.h"
#include <stdio.h>
#include "cuda_test.cu"
int main( int argc, const char* argv[] )
{
testfunc();
return 1;
}
main.h:
#ifndef main_h
#define main_h
extern float PI;
#endif
testfile.c:
#include "main.h"
float PI = 3;
cuda_test.cu:
#include "main.h"
#include <stdio.h>
void testfunc()
{
printf("Hello from cudafile: %E", PI);
}
This yields the following error:
1>------ Build started: Project: cuda_min, Configuration: Debug Win32 ------
1>cuda_test.cu.obj : error LNK2001: unresolved external symbol "float PI" (?PI##3MA)
1>D:\Backup\diplomarbeit\cuda_xanthos\cuda_min\Debug\cuda_min.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
When passing the variable PI to the function testfunc, I get the desired behavior. This is what I am doing in my project (which actually uses the CUDA-device), but I really do not want to pass about 20 variables to my functions.
I suppose I am missing some setting for nvcc...
Any help would be much appreciated.
.cu is compiled and linked as .cpp, not .c. So, you can either rename your .c files to .cpp, or use extern "C" in your .cu file.
I want to work with OpenCV2.4.2 . and I tried a simple progam to test if it'll work here is the code :
#include "stdlib.h"
#include "stdio.h"
#include "math.h"
#include "cv.h"
#include "highgui.h"
int main(int argc, char *argv[])
{
// Nothing but create a window
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
cvWaitKey(0);
return 0;
}
wenn I try to build and run this I get this error message from Eclipse :
fatal error: opencv2/core/core_c.h: No such file or directory
line 63, external location: D:\opencv\include\opencv\cv.h C/C++ Problem
Symbol 'CV_WINDOW_AUTOSIZE' could not be resolved source.c line 18 Semantic Error
Any Idea why it doesn't work ??
Because the compiler does not know the location of opencv headers.