Author Topic: Adding a library - USB  (Read 183 times)

Offline MikeSD

  • Single posting newcomer
  • *
  • Posts: 1
Adding a library - USB
« on: June 20, 2017, 08:10:39 pm »
I've just installed CodeBlocks and like the IDE.  And I do understand this is an IDE and separate and apart from the compiler, linker, etc.  But the point of me going to an IDE is to simplify the build process and not have to deal with creating make files and such.  I have tested a few simple programs and everything seems to work fine.

But now, I need to use a library that's not included.  This question, I guess, should be a general question about adding any library, but I'll mention that it's the (or a) libusb library.  And I know this is related to the compiler and linker but all googling I do, brings me back to makefiles and compiling from the command line.  I'm trying to avoid all that ;).  And I can't figure out how to install or place the library file, in my system, that was setup by the install of CodeBlocks. (so it's related to this IDE).

So please bear with me, on this questions.

First, my system.  It's an x86 based system, 64 bits, running Windows 7.
I will compile using the GNU GCC compiler that came with my download.
I downloaded this package: codeblocks-16.01mingw-setup.exe

1) There are two usb library packages
a) ​libusb-1.0.9
b) libusb-compat-0.1.4 (this looks like older version but does have references to Windows)

Which should I be using for a Window7 setup? Or can either be used?

2) Are there any detailed instructions on how to install a library (i.e. libusb) to my GCC system, or in particular, my CodeBlocks IDE, using gcc?
 
3) If compiling is still required, can I import and compile one of the LibUSB library source projects using this IDE and the GCC compiler?

4) And if compiling is still required, and the CB IDE can be used, where does the lib go, after it's compiled?

5) And I don't know if this is "simple" or just "stupid" but *.lib files tend to be used with x86 systems and I think gcc makes *.a files for libraries.  Should I be looking for *.lib file for the usb library or a *.a, for use on my gcc compiler on x86?

6) Bonus question. RE #6. was that "simple" or "stupid"? :D

Thanks,
« Last Edit: June 20, 2017, 08:13:31 pm by MikeSD »

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1370
Re: Adding a library - USB
« Reply #1 on: June 21, 2017, 12:21:57 am »
Quote
1) There are two usb library packages
a) ​libusb-1.0.9
b) libusb-compat-0.1.4 (this looks like older version but does have references to Windows)

Which should I be using for a Window7 setup? Or can either be used?
Not topic of this forum... If the interface to libusb is c++ you have to use the libusb version that is compiled with your compiler, because with c++ you can not use different compilers for library and binary (the easy explanation)

Quote
2) Are there any detailed instructions on how to install a library (i.e. libusb) to my GCC system, or in particular, my CodeBlocks IDE, using gcc?
Fast way:
Install the library on your system, add the include path in the search directory settings and add the library in the linker settings.
You can read a bit here: http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F
If you have any problems during compiling:
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Quote
3) If compiling is still required, can I import and compile one of the LibUSB library source projects using this IDE and the GCC compiler?
It is possible (codeblocks is a build system and can do all the things any other build system can do), but i would recommend to use the way the library maintainer provides to you. Especially if you are a beginner. There are 1000 ways to build a c/c++ project. Codeblocks can not provide a import functionality for every way...

Quote
4) And if compiling is still required, and the CB IDE can be used, where does the lib go, after it's compiled?
Where you tell codeblocks to put the library.
I think here is a misunderstanding at your side: On windows there is no default install path for a library. You copy it anywhere on the disk and use it. There are package manager out there for windows and if you are using one you should ask this question in a forum for this packet manager

Quote
And I don't know if this is "simple" or just "stupid" but *.lib files tend to be used with x86 systems and I think gcc makes *.a files for libraries.  Should I be looking for *.lib file for the usb library or a *.a, for use on my gcc compiler on x86?
This has nothing to do with x86 (on amd64 systems the names are the same) but with the compiler. The microsoft compiler puts out lib files and gcc a files. They are not binary compatible but there are tools out there that can convert from lib to a file. I posted this in some older thread, you can search here for it...

Quote
6) Bonus question. RE #6. was that "simple" or "stupid"? :D
i don't understand what you are asking for, but it is only bonus soooooooooo ;)