Thread: Mutiple source files for one program

  1. #1
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257

    Mutiple source files for one program

    Hey,

    I am trying to write 3 functions that will be available for a number of programs. After reading this tutorial "Multiple source files for one program (C++ example)", I wrote a header file that defines all three functions and three separate source code files to define those functions. When I include the sourse file in the main program it doesn't recognise the functions.

    here's the source file:

    Code:
    # include <stdio.h>
    # include <math.h>
    # include <STDLIB.H>
    
    # define BIT01 0X00000001
    # define BIT02 0X00000002
    # define BIT03 0X00000004
    # define DATAMASK18 0XFFFF800
    
    #ifndef CreateWord_H 
    #define CreateWord_H 
    
    int CreateLabel(int number /*Input Octal label*/);
    int CreateWordAnalog(int label, float scale, int nbits, float value);
    float DecodeArincAnalog(int word, float scale);
    
    #endif
    and the include statement:

    Code:
    # include <CreateWord.h>

    The error messages:

    Code:
    create a word.obj : error LNK2001: unresolved external symbol _DecodeArincAnalog
    create a word.obj : error LNK2001: unresolved external symbol _CreateWordAnalog
    Debug/create a word.exe : fatal error LNK1120: 2 unresolved externals
    Error executing link.exe.
    Is there anything I'm missing?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Is the project set up with multiple source files? Something like this?
    http://img77.echo.cx/my.php?image=project6dq.gif
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    The project only contains the main function, the header and the other function files are in another project. They show up as externals in the main project.

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Don't #include source files.
    Do add source files to the project build.
    Do define these functions in the additional source files.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    So I'll have to add all the function definition files in the project, but # include the header file, right?

    sorry, I'm still trying to figure out this whole project, workspace business with Visual C++.

    Thanks,

    A.

  6. #6
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    and on another topic:

    if the window that displays the ClassView and FilesView doesn't appear, how do I open it?
    If you use MS Visual C++.

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by earth_angel
    if the window that displays the ClassView and FilesView doesn't appear, how do I open it?
    If you use MS Visual C++.
    View -> Workspace
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    All the problems in my world are solved.



    for now..........


    Thanks dave.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class Inheritance over multiple source files
    By Swarvy in forum C++ Programming
    Replies: 7
    Last Post: 11-11-2008, 10:03 AM
  2. pseudocode for multiple source files
    By Calef13 in forum C++ Programming
    Replies: 4
    Last Post: 11-13-2007, 09:07 AM
  3. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  4. Replies: 26
    Last Post: 06-15-2005, 02:38 PM
  5. Multi - File Program not finding files
    By johnh444 in forum C++ Programming
    Replies: 2
    Last Post: 07-03-2004, 01:48 AM