-1

I have a project that compiling with GCC, and now I want open and run it with visual studio.what should I do?

I created new C project in visual studio and then add .c files to Source Files and add .h files to Header Files,too. But what should I do for makefile?

I see these error:

Error   9   error LNK2005: _main already defined in basic00.obj fp.obj

Error   10  error LNK2001: unresolved external symbol _optind   fp.obj

Error   11  error LNK2001: unresolved external symbol _optopt   fp.obj

Error   12  error LNK2001: unresolved external symbol _optarg   fp.obj

Error   13  error LNK2019: unresolved external symbol _getopt referenced in function _main  fp.obj

Error   14  error LNK2001: unresolved external symbol _opterr   fp.obj

Error   15  fatal error LNK1120: 5 unresolved externals C:\Users\user\Documents\Visual Studio 2008\Projects\project.c\Debug\project.c.exe
nIcE cOw
  • 24,468
  • 7
  • 50
  • 143
  • possibly correlated with http://stackoverflow.com/questions/10404448/getopt-h-compiling-linux-c-code-in-windows In short getopt is from POSIX, but VS 2008 does not support it. Either rewrite your code or supply some drop-in replacement. – Grzegorz Szpetkowski Oct 06 '14 at 13:59

1 Answers1

0
  1. You need to remove the second main() function.
  2. You're using optind, optopt etc. These functions are defined in POSIX library, VS compiler doesn't have these ones. You need to remove these calls.
Eldar Dordzhiev
  • 5,105
  • 2
  • 22
  • 26