Menu

Using GNU Libraries/Functions in Dev C++

B Cox
2009-07-20
2012-09-26
  • B Cox

    B Cox - 2009-07-20

    Hello:

    There are numerical functions in the GNU Scientific Library that I need to use in my C++ code:
    http://linux.duke.edu/~mstenner/free-docs/gsl-ref-1.1/gsl-ref_19.html
    But how do I do tihs in Dev C++?
    Thank you!

     
    • cpns

      cpns - 2009-07-23

      > NLSfitting.cpp:4: error: `size_t' does not name a type

      size_t is defined in <string.h>/<cstring>

      The other errors suggest that you have not included the necessary files top define GSL types.

      You remain somewhat reticent at providing information. This is the same error you posted to someone else's thread four days ago, yet in between times you have apparently had an installation that could not have built anything. How was that so?

      Currently you are experiencing compiler errors; as I have mentioned twice now, it is unlikely that other than the DevPak that a binary download of the library is built for MinGW so you will get linker errors when you have resolved the compiler issues. You are consistently avoiding addressing that issue. Either you know better than me, or you just don't believe or understand the issue.

      Your project remains exactly where I told you twice not to put it "C:\Dev-Cpp\Projects". If you are not going to take advice, don't ask for it!

      Where exactly did you install the GSL library? Not truely in C:\Dev-Cpp I hope, but some subfolder of it at least is not somewhere else entirely! For compilation the critical thing is where you placed the header files. The compiler command line specifies only the following include folders:

      "C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"
      "C:/Dev-Cpp/include/c++/3.4.2/backward"
      "C:/Dev-Cpp/include/c++/3.4.2/mingw32"
      "C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

      I do not recommend that you put the GSL headers in either of these, instead you should add an additional folder to the list. Note that you need to add it to the Project options, not the Compiler options; these are applied to projects only on creation. You need to perform steps 3, 4, 5 and 6 form your own list. You will have to make similar changes for the linker to find the library files (.a). But as I have already mentioned, if you downloaded the source package, you do not have the library file and will have to build the source in the way Wayne first suggested.

      Clifford

       
    • cpns

      cpns - 2009-07-23

      PS...

      I looked at the example you posted. Because it includes the GSL headers with the gsl/ prefix. If you placed the headers in "C:/Dev-Cpp/include/gsl", you do not need to change the include folders list after all. Since the log you posted implies that the headers were found, it seems likely that is the case (but why do I have to guess and infer when you might just tell me!?)

      However, the line numbers in your log do not appear to match the code you linked to. Post the actual code that these messages relate to! For example size_t is not used until line 10 of the code, but your error message is reported for line 4. My guess is that you have omitted all of the GSL includes; in which case you really are wasting my time!

      Clifford

       
    • Wayne Keen

      Wayne Keen - 2009-07-20

      I think I posted on this, several years ago. What I did was:

      (1) Download the GSL library
      (2) Build it under MinGW/MSYS
      (3) Bring it into my Dev setup
      (3) Include the headers in my code
      (4) Link the libraries
      (5) Compile

      Now, I seem to recall there is a GSL DevPack that you can download, and
      this should let you avoid (1) - (3) above.

      Wayne

       
    • B Cox

      B Cox - 2009-07-20

      Thanks, Wayne. I went to
      http://devpaks.org/details.php?devpak=91

      But when I opened the executable for the download link
      http://samotyjak.pwsz.elblag.pl/devpak/GSL-1.6-gcc3.3.1-1cml.DevPak

      It opened up 'Package Manager' with several compnents. I am not sure where to install these components in my Bloodshed C++ folder structure so I can access the GNU math libraries. The components inside the Package Manager were
      binutils
      dev c++ map file
      dev c++ help file
      gcc-core
      gcc-g++
      gnu debugger
      gnu make
      mingw runtime
      windows32 api

      I am also hesitant, because I'm not sure if installing these components would conflict w. the components I already have from the Dev C++ 4.9.9.2 installed on my computer.

      Thank you for clarifying.

       
    • cpns

      cpns - 2009-07-21

      The DevPak file is not an 'executable' it is a data file associated with Package Manager.

      The components you have listed are those already installed. You do not need to do anything with them. They are not part of the DevPak you are installing, and will not be modified by the DevPak. The package manager allows both the installation and removal of components - that's why you see the existing components.

      The DevPak will define where the libraries are installed; I suggest that you just let it do its job.

      I have found that some (perhaps all ) DevPaks assume that you have Dev-C++ installed in c:\dev-cpp, if you have not, some templates may need to be modified. They are plain text files so that is not too difficult.

      The GSL DevPak may or may not provide a project template. If it does, it will have all the necessary compiler/linker options set to building GSL applications. Check File->New->New Project..., or just look in the Templates folder.

      Clifford

       
    • B Cox

      B Cox - 2009-07-22

      When I go to Tools>Package Manager, I see my Package Manager (v. 2.2.6) in which I have packages such as gcc-core, gcc-g++, GNU Debugger, GNU Make etc.

      But when I create a new project and try to run the example found in GNU,
      http://linux.duke.edu/~mstenner/free-docs/gsl-ref-1.1/gsl-ref_36.html#SEC465
      I still get compiler errors as if it doesn't recognize the math functions used in the example.

      The goal is to be allowed to use GNU library w. its many math functions in my Dev C++ environmt. But what is the difference btw downloading the GSL DevPack and

      1) downloading gsl-1.8-src.exe
      2) Open Dev C++ and create a new project
      3) Click Project->Project Options menu
      4) Goto Directories tab
      5) Goto "Include Directories" sub-tab
      6) Enter C:\Program Files\GnuWin32\include and press Add button
      7) Goto Parameters tab
      8) Click on button "Add library or object"
      9) Navigate and select C:\Program Files\GnuWin32\lib\libgsl.a
      10)Click on button "Add library or object"
      11)Navigate and select C:\Program Files\GnuWin32\lib\libgslcblas.a
      12)Click on button "Add library or object"
      13)Navigate and select C:\Program Files\GnuWin32\lib\libgslcblas.dll.a
      14)Add the path C:\Program Files\GnuWin32\bin to system runtime, or copy the dlls libgsl.dll and libgslcblas.dll to the location where you want to run your .exe

      ??

       
    • cpns

      cpns - 2009-07-22

      > But what is the difference btw downloading the GSL DevPack and [...]

      I have no idea since i have not downloaded the DevPak (in fact I no longer install Dev-C++). Not all DevPaks work in the same way, they are merely an installation mechanism for libraries, headers, and templates and other components. A DevPak may include some or all of these.

      In the case of a library, it will at least copy the .a, .h and if used .dll files to an appropriate location. Usually within the Dev-C++ installation folder as subfolders of the LIB and INCLUDE folders. It would certainly not place them in a folder such as "C:\Program Files\&quot; because a) they are not program files, and b) MinGW make does not always work corrctly with paths containing spaces. You would know that had you read the "Read First" thread that you have been repeatedly referred to.

      You have provided a long list of steps that you have taken, but you may have saved yourself (and us) a lot of time had you simply posted the Compile Log text (also mentioned in the Read First thread). That will tell us unambiguously exactly how your project is set up rather than how you believe it is set up, and exactly what the errors are, which is an important diagnostic tool. You are asking us to work blind by not providing all the diagnostic information available.

      Although the steps you listed are at least one way of linking a library, there is some redundancy. If you specify a library fully via the "Add library or object" button, then adding a library search path in the directories is unnecessary. Adding a library search path allows you to use linker options such as -lgsl -lgslcblas instead of a fully qualified path and filename.

      I suggest that you need either libgslcblas.a or libgslcblas.dll.a but not both. One is a static library, the other is an export library for a DLL version of the library. It is simplest, less error prone, and easier to deploy to use the static library - at least initially.

      From the filename I imagine that gsl-1.8-src.exe is a self extracting archive of the GSL source code. You will need to build this source in order to obtain the necessary library files. If you already have .a files, they will not work unless they were specifically compiled for the MinGW toolchain. Any distributed binaries are likley to be for Linux or possibly Cygwin; MinGW distributions are less common - the DevPak is such a distribution, which is why it is recommended.

      Clifford

       
    • B Cox

      B Cox - 2009-07-22

      'Unexpected Error' msg box appears when I run an example from GNU. It also does not allow me to save the .cpp to the project. The project was created using steps 2)-14). The bug report was:

      Application version: 4.9.9.2

      Machine info

      Platform : Windows NT
      OS version : version 5.1 (build 2600)
      Additional info: Service Pack 3

      The following error occured in version 4.9.9.2:
      Cannot create file C:\Dev-Cpp\Projects\Project1.dev (at address 0x0041BDC9)

      Please include a description of what you were doing before the error occured (please give as much precisions as possible) :

      State information follows:
      Stack trace:


      0058F80A (0018E80A): ShowExceptionInfo (ExceptionsAnalyzer - 566)
      0058F9FF (0018E9FF): TExceptionsAnalyzer.GlobalExceptionHandler (ExceptionsAnalyzer - 574)
      0057AA5F (00179A5F): TdevINI.UpdateFile (project - 2232)
      00577988 (00176988): TProject.Save (project - 1321)
      00558A37 (00157A37): TMainForm.actSaveAllExecute (main - 2977)
      0055A08F (0015908F): TMainForm.PrepareForCompile (main - 3671)
      0055A2EB (001592EB): TMainForm.actCompRunExecute (main - 3736)
      0059105B (0019005B): (devcpp - 230)
      00591079 (00190079): (devcpp - 230)

       
    • cpns

      cpns - 2009-07-22

      Look; I am providing a great deal of information, and you appear to be ignoring it! In your other thread, I already said not to build projects in c:\dev-cpp or its sub-folders, yet that is exactly what you are dong here!

      Moreover I have already pointed out that the steps you have listed are likely to be incorrect. You may be able to convince me that they are correct, but to do that you have to address the issues I raised to do that.

      If you make it a two way process you'll get to the bottom of this much quicker, but currently it feels as if I am talking and you are not hearing. Some feedback on my comments would be helpful in both checking your understanding and furthering my diagnosis. I am not giving answers yet, I am investigating the problem, but you are not helping; and in a remote diagnosis you do need to do that. If you don't see an answer, it is not because I am trying to be unhelpful, it is because I am trying to get you to provide the information needed to give an answer.

      Clifford

       
    • B Cox

      B Cox - 2009-07-22

      I have reinstall Dev C++ altogether now using the previous forum posts. And downloaded gsl 1.8 in the same folder as Dev C++. C:\Dev-Cpp.

      At this point, I still have to find the exact directions of how to create a project and run a .cpp that allows me to access GNU math libraries. As before, the end goal is being able to run the nice example GNU community provided

      http://linux.duke.edu/~mstenner/free-docs/gsl-ref-1.1/gsl-ref_36.html#SEC465

      If that runs, then it provides a nice template for solving our real problem numerically using Dev C++. Our current software does not allow for numerical integration on the complex plane.

       
    • B Cox

      B Cox - 2009-07-22

      The beginning of the error log looks like this:

      Compiler: Default compiler
      Building Makefile: "C:\Dev-Cpp\Projects\Makefile.win"
      Executing make...
      make.exe -f "C:\Dev-Cpp\Projects\Makefile.win" NLSfitting.o
      g++.exe -c NLSfitting.cpp -o NLSfitting.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

      NLSfitting.cpp:4: error: `size_t' does not name a type

      NLSfitting.cpp:10: error: expected ,' or...' before '*' token

      NLSfitting.cpp:12: error: ISO C++ forbids declaration of `gsl_vector' with no type

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.