Thread: makefile and windows compilation

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Most likely, yes. The warning says that there's no prototype for function Process, so the compiler guesses what it looks like, which is bad.
    You can also comment out all the unreferenced variables, because VS is telling you they are never used anywhere.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    I found out the function definition of Process(), was not included in the main.c or main.h, so I added it to main.h. The warning went away and it compiles without error or warning (just the the "unreferenced local variable", which i will handle later.

    Again, this compiles and links perfectly in Unix or cygwin. What could the problem be ?
    Last edited by inkare; 06-26-2008 at 10:43 PM.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Did you merely add a...
    something Process();
    ...to the header file?
    Without actually implementing such a function?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    Quote Originally Posted by Elysia View Post
    Did you merely add a...
    something Process();
    ...to the header file?
    Without actually implementing such a function?
    lol, no, "process.c" is a file which contains the function "Process()" and a bunch of other functions. The function declaration of Process() wasn't included in mc_main.h, so I included it there (and the bunch of other functions there).

    But its giving me a linking problems. Process.h doesn't exist, so I'm wondering if I need to create that. But again, it works without problems in unix.

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, then.
    Two other possibilities:

    1) Did you copy the exact definition of Process? It must match the header of the function exactly.
    2) You aren't compiling the process.c file. Is it excluded? Right-click it and select properties.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    Quote Originally Posted by Elysia View Post
    Well, then.
    Two other possibilities:

    1) Did you copy the exact definition of Process? It must match the header of the function exactly.
    2) You aren't compiling the process.c file. Is it excluded? Right-click it and select properties.
    The definitions match the function headers exactly. I think you are right with #2, i changed the name of process.c to something else, to see if I would still get the same errors and I do indeed. What must be the reason why its not reading it ? Do I need to create header file for it and include it in main.c? Main calls functions from process.c
    Last edited by inkare; 06-26-2008 at 10:42 PM.

  7. #22
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You said you were in VS. Therefore, you have a solution, which has a project. That project should have "source files" (or something similar). Both of the .c files need to be listed there.

  8. #23
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    Quote Originally Posted by tabstop View Post
    You said you were in VS. Therefore, you have a solution, which has a project. That project should have "source files" (or something similar). Both of the .c files need to be listed there.
    Well all I did is compile main.c, and it created a project for me ? Is that wrong? Can I add process.c to the project? Shouldn't it find project.c by itself?

  9. #24
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by inkare View Post
    Well all I did is compile main.c, and it created a project for me ? Is that wrong? Can I add process.c to the project? Shouldn't it find project.c by itself?
    And how would it do that? Search your hard drive for any and every file with a .c extension in the hope that it has the functions you need? Add project.c to your project.

  10. #25
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    Thanks a lot for your help guys. I've been since using Matlab for a while now, and the entire compilations and linking stuff doesn't make sense to me anymore. I went into project and added all the files necessary to the project. It works, except one last part in linking. This is the error I get.

    --------------------Configuration: mc_main - Win32 Debug--------------------
    Linking...
    main.obj : error LNK2001: unresolved external symbol _dist
    Debug/main.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    main.exe - 2 error(s), 0 warning(s)


    Now, dist is an inline function included in another file (utilities.c), which doesn't have a header file. Does the linker look for it, or am I supposed to somehow tell it its there?

    Code:
    inline double dist(double x1, double y1, double z1,
                double x2, double y2, double z2)
    {
      double d;
      d=sqrt(DSQR(x1-x2)+DSQR(y1-y2)+DSQR(z1-z2));
      return(d);
    }

  11. #26
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you need utilities.c, add it to the project.

  12. #27
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    Quote Originally Posted by tabstop View Post
    If you need utilities.c, add it to the project.
    I did !!

  13. #28
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    I copied the function dist in the bottom of main and it compiles and works. I don't know why it wasn't able to find it despite utilities.c being added to the project.

    I'm trying to run this code in debug mode, but the code takes a file as input. When it gets to the part with the input file (below), debug mode crashes, because i'm not able to provide it with the file. But when I run it from the command prompt, it's able to read the input file. Anyone knows the trick behind it?

    Code:
    int main(int argc, char *argv[])
    {     
    
      input_file_ptr = fopen(argv[1], "r");
    
    ....
    }

  14. #29
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you right click on the project, and select properties, you should see "Debugging" under Configuration Properties. One of the slots on this page is Command Arguments, which should be the things passed to your program in argv.

  15. #30
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    Quote Originally Posted by tabstop View Post
    If you right click on the project, and select properties, you should see "Debugging" under Configuration Properties. One of the slots on this page is Command Arguments, which should be the things passed to your program in argv.
    You mean right click the DSP file or the project tab in VS ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with makefile
    By New_Programmer in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2009, 04:55 PM
  2. Replies: 1
    Last Post: 06-27-2008, 06:41 PM
  3. Makefile problem
    By TriKri in forum Windows Programming
    Replies: 8
    Last Post: 06-26-2008, 11:06 AM
  4. makefile help
    By the Wookie in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2003, 07:31 PM
  5. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM