Home » Community » Newbie corner » How to include files .h or .cpp as external library? (How to include files .h or .cpp as external library?)
|Re: How to include files .h or .cpp as external library? [message #52696 is a reply to message #52682]
||Tue, 12 November 2019 16:22
Registered: August 2018
I dont really get your Error I think you miss some lib's.
I will asume you are using this : https://www.wxwidgets.org/
Even If you are using Mac OS X, I will explain how to use this external lib on windows with Mingw (TheIDE Default compiler). I guess the theory is the same for Mac OS X.
First of all, to use external lib's with Mingw you (80% of time) need to compile source of the lib with your compiler.
(Here is the tutorial I used to do it : https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW)
After downloading and unzipping wxWidgets, you must (by command prompt) move to Build/Msw
and type: mingw32-make -f makefile.gcc SHARED=0 UNICODE=1 BUILD=release clean
then : mingw32-make -f makefile.gcc BUILD=release SHARED=0 MONOLITHIC=1 UNICODE=1
(Note to do mingw32-make you need to inquire Mingw Bin folder path to your PATH variable environment (Here is a shard of my PATH Variable : ... ;C:\Upp\upp\bin\mingw64\64\bin;C:\Upp\upp\bin\mingw64\32\bin ; ... ))
At the end of compilation (it took 1 hour to me) go to lib file wxWidgets/lib and you should find lot of "*.a" in gcc_lib folder. All this .a are lib's that you can use with your compiler.
On windows ( I think the theory is the same on Mac OS X) when you want use lib you must (in most case) say to your IDE Where to find several file's :
First of all, "include files"(all .h referencing external lib(.a))
In the case of TheIDE, you must go in "Setup-> Build Methods" then in include directories, right click and add wxWidget include folder as follow. (Note, I include two different folder from wxWidget, one contain Setup.h when the other contain all class and function definition)
Second thing to add is lib directories ( all *.a)
Same as include :
then press "Ok".
Here is the little programme I use to test my build (to find a better exemple go here https://docs.wxwidgets.org/stable/overview_helloworld.html= :
// wxWidgets "Hello world" Program
// For compilers that support precompilation, includes "wx/wx.h".
using namespace Upp;
If you try to compile it at this time, you will get Linking error, Even if we had add Lib and Include to compiler setting, we forget to tell compiler what lib to use. To do this, you must go in TheIDE and right click your package and go to Package Organizers
Then, right click and select adding a new lib :
Add all this lib : wxzlibd wxexpat wxjpeg wxmsw31u wxmsw31u_gl wxpng wxregexu wxregexud wxscintilla wxtiff wxzlib
Then when you compile, it should works !
Hope this helped you.
Have a good day
Edit 1 : After trying I got some Linking Error, I will dig up to find what lib is missing but I still post this respons to help you.
@To Upp community, if someone find a misstake or I say bullshit feel free to correct me, I will update the poste.
my github : https://github.com/Xemuth
Current Time: Sun Jul 05 18:17:18 CEST 2020
Total time taken to generate the page: 0.00938 seconds