Emidio Planamente 's Homepage

Home GNU/Linux Programming Technology Sport Others Contact
HTML validator CSS validator

 

Visual Studio


1. Compiling errors

2. Execution errors

3. Linking errors

4. Tricks


1. Compiling errors


1.1. Precompiled header


You get the following error:


  fatal error C1010: unexpected end of file while looking for precompiled header directive


PROBLEM:


The project has been generated so that the StdAfx.h should be used.


SOLUTION 1:


Include this library in each file.


SOLUTION 2:


Change the project settings:


   - Project

     - Project properties

       - Configuration properties

         - C/C++

           - Precompiled Headers

             - Create/Use precompiled headers: Not Using Precompiled Headers


1.2. Redefinition of a type defined by Windows


You get the following error:


  error C2365: 'Unknown' : redefinition; previous definition was a 'enumerator'


PROBLEM:


You try to define a type that is already defined by Windows.


SOLUTION (very dirty!!!):


Remove the inclusion of the windows definition by adding the  preprocessor in the project setting.


Change the project settings:

   - Project

     - Project properties

       - Configuration properties

         - C/C++

           - Preprocessor

             - Preprocessor Definition

               - add _WINIOCTL_ (this is maybe the problematic label)


2. Execution errors


2.1. DLL not found


You get the following error:


  The dynamic link library xxx.dll could not be found in the specified path ..."


PROBLEM:


The exe file needs a DLL that can't be found.


SOLUTION:


Copy the dll in the same directory where is placed the exe file.


3. Linking errors


3.1. Strange errors about a missing function are displayed during the link process


PROBLEM:


Missing libraries.


SOLUTION:


Change the project settings:

   - Project

     - Project properties

       - Configuration properties

         - Linker

           - Input

             - add yourLibrary.lib


3.2. Unresolved external symbol


PROBLEM 1:


A member declared as static in the .hpp file has not been correctly declared in the .cpp file.


SOLUTION:


If the member is


   private:

     static std::string _myString;


in the cpp file there must be this entry:


   /*static*/ std::string MyClass::_myString = "hello";


PROBLEM 2:


Missing file into project.


In the file1.cpp there is a call to method declared in file2.cpp. If file2.cpp is not included in the project,  the compiler can work without problems, but the linker gives an error.


SOLUTION:


Include at least file2.cpp in the project (better is if you also include file2.hpp into the project).


4. Tricks


4.1. Adding a directory with header files


PROBLEM:


You don't want to specify the exact path each time you use a header file.


SOLUTION:


Add the path of the desired include file(s) in the project settings.


Change the project settings:


   - Project

     - Project properties

       - Configuration properties

         - C/C++

           - General

             - Additional Include Directories: your_directories


4.2. Don't know the name of a library to be included


PROBLEM:


I don't know the name of a required library.


SOLUTION:


  - select the method, type, ... that requires a library

  - press F1

  - press the "Sync contents" button


It's possible to find out the required library giving a look at the resulting window.


4.3. A long line is displayed on more lines


PROBLEM:


The word wrapper is active.


SOLUTION:


  - Tools

    - Options

      - Text editor

        - All languages

          - Settings

            - remove "Word wrap"


4.4. Shortcuts


  CTRL + SPACE: pop down list for words completion

  ALT + click : select text with a box

  CTRL + click: mark whole word

  ALT + TAB   : switch to next opened file

  TAB         : if more lines are selected -> add tab to all the selected lines

  SHIFT + TAB : if more lines are selected -> del tab to all the selected lines

  CTRL + TAB  : switch between the windows

  CTRL + ^    : jump to the respective bracket

  CTRL + F2   : set mark

  F2          : jump to next mark

  CTRL + SHIFT + 8: show/hide tabs and spaces

  F3          : search next statement

  SHIFT + F3  : search previous statement

  F4          : jump to the next line in output window

  F9          : set/remove breakpoint

  F5          : build debug version and execute it

  CTRL + F5   : build release version and execute it

  CTRL + F7   : compile only current file

  F7          : compile and build current project



Emidio Planamente

Last modified on 2005-07-10