Using external library with Visual C++

This is a discussion on Using external library with Visual C++ within the C Programming forums, part of the General Programming Boards category; Hello, I am trying to use the GNU Scientific library as part of my C program. I am devloping under ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    15

    Using external library with Visual C++

    Hello,
    I am trying to use the GNU Scientific library as part of my C program. I am devloping under Windows XP, using the Visual C++ compiler. I created this simple program to try to get the hang of using the library, however I cannot get it to link for the life of me.

    Here is the code:


    Code:
    #include <stdio.h>
    #include <C:\GnuWin32\include\gsl/gsl_cdf.h>
    
    extern double gsl_cdf_chisq_Pinv (const double P, const double nu);
    
         int main (void)
         {
    		double y=0;
    		y = gsl_cdf_chisq_Pinv (0.000085, 100);
    		printf(  "Ans is: %e \n", y);
           return 0;
         }

    Here is the Error message:

    --------------------Configuration: EarlyPass - Win32 Debug--------------------
    Compiling...
    EarlyPass.c
    Linking...
    EarlyPass.obj : error LNK2001: unresolved external symbol _gsl_cdf_chisq_Pinv
    Debug/EarlyPass.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

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

    Any suggestions?

    Thanks in advance.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,764
    Obviously you didn't include whatever source file gsl_cdf_chisq_Pinv is defined in.
    Add all C or C++ files to the project and then compile.
    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.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    15
    That's what I thought. However, I tried both adding those files into the project, and then as is shown here I put in the file location for the *.h file, and the required *.h files now show under "External Dependencies" on the left.

    Unless of course I'm missing something out.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,764
    Does it come with a .lib file and a dll for the code or are they bundled in source files?
    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.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    15
    It's an open source library, and there is a library in the form of an *.a file, and another in the form of a *.dll.a....

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    15
    Here is a link to a screen shot of the folder with the "library".

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,764
    Link doesn't work (for me at least). Try photobucket or similar image hosting solutions.
    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.

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    15
    Sorry about that. Try here.

  9. #9
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,764
    I have no idea what ".a" files are. Sorry.
    Someone else may have knowledge. Don't give up hope.
    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.

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    15
    Thanks Elysia, I shall not give up hope!

  11. #11
    Registered User
    Join Date
    Apr 2008
    Posts
    15
    Sorry to bring this up again, but anyone have any ideas?

  12. #12
    Registered User
    Join Date
    Aug 2006
    Posts
    99
    Have you actually BUILT the libraries?
    .a is a normal unix library file, not windows.

    Use the GSL Source code to build the actual library for Visual C++, then link to the resultant .lib file(s).
    I don't see that they have a standalone DLL, but you could build that.
    Last edited by rdrast; 04-18-2008 at 08:56 AM.

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    15
    I downloaded an executable which "installed" it. I am not too sure what that exactly means though. I tried looking for the link, but I can't seem to find it at the moment.

    How would I go around building it?

    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. Templates and Macros plus more...
    By Monkeymagic in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2007, 04:53 PM
  3. question about .net to 6.0 change causing errors
    By jverkoey in forum C++ Programming
    Replies: 17
    Last Post: 03-23-2004, 09:45 AM
  4. errors in my class....
    By o0obruceleeo0o in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2003, 03:22 AM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21