I am writing an Apache module for my internship. I am using C for this (I am not acquainted with Perl or Python that much).
I need to use an HTML Parser to solve the problem for which I am writing this module. I am considering libxml2 for this purpose.
I am confused how should I link the library in my module ? Should I link the library while compiling the module OR Should I use the LoadFile directive in the configuration file to load the library.
My main concern is that while I am developing this on Ubuntu, but I don't know what will be the OS running on the deployment server. So I want its deployment, complications free and successful.
EDIT: #Grim: thanks for replying :)
I compiled the module with the following commands:
apxs -I /usr/include/libxml2/ -c mod_xmltest.c
sudo apxs -n xmltest_module -i mod_xmltest.la
I believe this does not link the libraries in the module, I was getting "Unresolved Symbols" error when starting the server, so I used the LoadFile directive to load libxml2 library. It seems to work.
Do you think there can be any issues this way? I think this makes my module more portable, as on the deployment server the admin can explicitly specify the location of the libxml2 library.
You should link the library while compiling your module.
There are of course the usual portability issues (at least then it comes to a non-posix OS). In this case some of them are solved by apxc. It's impossible to say which complications that might occur, but nothing of what you describe should cause any.
Related
I am trying to build the latest GNURadio package on my development system. Unfortunately this system configuration is tightly controlled and I can't just install new packages of software on it as it is used to develop a product and all development systems are kept in lockstep. We are currently on an older version of RedHat.
While I cannot modify the system includes I can download and use newer versions of packages locally (in non-system directories) as long as that doesn't affect the product build/debug environment. Normally this isn't a problem.
However, when building GNURadio I found that our development platforms use an older version of the Boost libraries than is required to build GNURadio. So, I got the latest version of Boost and extracted it into my local (home) directory. I found several directions for, I thought, instructing CMake to use additional include directories. Unfortunately, this hasn't seemed to work with the Boost libraries. CMake keeps complaining that it finds the older version of Boost and not the newer one I have extracted locally.
I have tried using
-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=<dir>
and
-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES_BEFORE=<dir>
and this had no effect. I then tried adding the following to the top-level CMakeLists.txt file:
SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
SET(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES <dir>)
or, even
include_directories(BEFORE <dir>)
Again, no joy.
I did a bit of digging and found that there is a GrBoost.cmake module and it had an additional configuration for the boost directory so I added this:
list(PREPEND BOOST_LIBRARYDIR "<dir>")
to the top of the file. Again, no luck.
I've never used CMake before (and I'm not really keen on learning yet another build system if I don't have to - our company just switched to bazel and I am coming up to speed on that) so I am flying blind here.
What do I have to do to get CMake to look in my local directory to find the Boost stuff I downloaded?
Ok. As it often happens, just after asking the question I was able to find an answer.
It turns out that there is a command-line option to CMake (CMAKE_PREFIX_PATH=<dir>) where you can specify additional base paths to search for CMake config files. I just added this to the command-line and it was found just fine.
I wasn't even aware that Boost came with such config files. Live and learn.
#vre's comment would have probably worked just as well (maybe better, in fact).
I have the following problem:
I am on Ubuntu 20.04 and I am trying to set up GNUstep which is required for certain source binaries I want to build
(for the sake of completion, the program I want to build is called Advanced Rendering Toollḱit, information can be found here: https://cgg.mff.cuni.cz/ART/).
When building with the clang-9 compiler, after invoking the make command, I receive this error message:
fatal error: 'objc/objc.h' file not found
I should mention that I am still fairly new to Linux in general. What I did was installing GNUstep via
sudo apt-get install gnustep gnustep-devel
as advised on the website (http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux). It resulted in receiving the mentioned error.
/usr/include/GNUstep/Foundation/Foundation.h:31:9: fatal error: 'objc/objc.h' file not found
The next thing I tried was to download the provided configuration scripts from the same webpage and execute them. When I did, I received the following feedback:
checking whether objc really works... no. I don't seem to be able to use your Objective-C compiler to produce
working binaries! Please check your Objective-C compiler installation.
If you are using gcc-3.x make sure that your compiler's libgcc_s and libobjc
can be found by the dynamic linker - usually that requires you to play
with LD_LIBRARY_PATH or /etc/ld.so.conf.
Please refer to your compiler installation instructions for more help.
configure: error: The Objective-C compiler does not work or is not installed properly.
Maybe I am getting something wrong, however, my whole intention of installing GNUstep is to make Objective-C programming possible on a non-Apple machine. Therefore I do not understand why it is complaining about a non-working Objective-C compiler (by the way, I end up with the same result when using gcc and g++ as compilers).
I did do some research and I came across some StackOverflow posts, suggesting me to install libobjc2, but I suspect this to be depreciated with Ubuntu 20.04.
I honestly don't know what's wrong and I highly appreciate a little push in the right direction! Many thanks in advance for helping me!
Although I cannot tell what exactly the bug was in my case, I got some external help and together we came up with a solution that worked for me.
For debugging purposes, we created a test user account in my Ubuntu environment and repeated the whole process. It worked flawlessly.
We concluded that something must have been wrong locally with regard to my user account. I am sure there was something wrong with my environment variables, although I failed to clearly identify the bug (I am a Linux beginner). I chose the easy way out, backed up important files, deleted and re-created my root user account and then it worked. I hope, this may help any other who has the same problem.
#skaak, thank you for your help and suggestions!
As people are pointing, if you want to use clang to compile objective C programs in Ubuntu you have to install libobjc2 (mainstream project here) but it's currently not packaged in Ubuntu. It's possible that there was a package with the same or similar name, as you found out, but that was a different thing. This manual installation worked for me:
wget https://github.com/gnustep/libobjc2/archive/v2.0.tar.gz
tar xvzf v2.0.tar.gz
cd libobjc2-2.0
mkdir build
cd build
export CC=`which clang`
export CXX=`which clang++`
cmake ..
make
sudo make install
I'm trying to learn how Kotlin Native works with this tutorial from JetBrains: https://kotlinlang.org/docs/tutorials/native/interop-with-c.html
But these tutorials are only fro macOS and Linux. Sometimes i use a windows computer and i want to know how it works there.
How can i add the libcurl library in windows and how can i add it to the libcurl.def file?
It isn't explained anywhere.
You need to install MSYS2, then in MSYS2 console install libcurl:
$ pacman -S mingw-w64-x86_64-curl
See https://github.com/JetBrains/kotlin-native/pull/1499
A more detailed step-by-step explanation on how to use dynamically built libcurl (aka DLL) with Kotlin/Native.
https://jonnyzzz.com/blog/2018/10/29/kn-libcurl-windows/
I do not think it is covered somewhere right now. The idea is still the same, and you should be able to make it work. The first step is to download and build libcurl locally from https://curl.haxx.se/libcurl/. There are instructions and documentation on how to build it. I do recommend to pick the Windows own implementation for SSL.
Once you are done with building you will have both the includes and the library. Note, on Windows, you will always have a static library. Even if you build curl as a dynamic library (DLL), you will have a generated static library that you use for linking. DLL is easier to build and use. A true static library is better because you will have no dependencies in your Kotlin/Native program binary. At that point, the tutorial instructions should work.
For Windows, if you need only basic HTTP communication, you can also try WinINet API which is a part of Windows and so no dependency is necessary. No hassle with the libcurl library.
See my example of how to use WinInet API with Kotlin MPP: https://github.com/localazy/kotlin-mpp-wininet
For macOS and Linux, instead of going through the hassle with libcurl manually, just use ktor clients: https://ktor.io/clients/index.html
I'm studying Kotlin too and it took many hours until I realize how to handle def file, includes and static library.
I made an example of how to use static library (curl with gzip and SSL support compiled with mingw) on kotlin-native. This way you dont need to dll files to be supplied with your app
https://github.com/carlosrafp/Libcurl-Kotlin-Native-standalone
On libcurl.def file you can see:
headers = curl/curl.h // path to curl header
libraryPaths = src/nativeInterop/cinterop // path to your static library
staticLibraries = libcurl.a // the static library
linkerOpts.mingw = -lws2_32 -lwldap32 // linking dependences
I based on the nice post of jonnyzzz:
https://jonnyzzz.com/blog/2018/10/29/kn-libcurl-windows/
I just installed msys2 and mingw64, with their development packages. I really need perl-Gtk3. Perl is msys2 and compiled with gcc-4.9.x, Gtk and friends are mingw and compiled with gcc-5.
Perl complains "Glib.c: loadable library and perl binaries are mismatched (got handshake key 0xde00080, needed 0xdd80080)" when building Glib. Should this work?
Thanks.
PS ... mingw-w64-x86_64-perl is simply unable to compile. And yes, I'm careful to use a mingw shell vs an msys shell.
Are you still having this problem? I have been able to build a Perl dev environment in MinGW64, current as of this time.
I have been able to build Perl Gtk2 / Gtk3 applications in that environment and the GUIs work. (Both Gtk2 and Gtk3 based). These applications are used in a production environment with several thousand desktop users. The application runs on OSX, Windows, and Linux, and can be packed into a binary for release as an "executable" for those operating systems. The details here are for the Windows version.
I do this by either installing the requisite system packages first with pacman, then as necessary rebuilding whatever system library packages that I may have modified, from source, using makepkg-mingw.
Then I build the requisite Perl modules using the CPAN shell, and the "look" command.
I use pkg-config to detect what library and header files are needed.
I then build (at minimum), the Perl Glib, Pango, Cairo, Gtk2, and Gtk3 modules using the perl Makefile.PL command.
The LIBS and INC options need to be added to that command to create a Makefile that includes the correct header files, and links to the correct libraries. The EXTRALIBS and LDLOADLIBS sections of the Makefile needs be correct.
Also ExtUtils::MM_Win32.pm ExtUtils::Liblist::Kid.pm needed to be edited due to the different archname reported by the MinGW64 perl.
I am only giving a general answer, because I was thinking offing a YouTube video on this. If this is a desired topic I will.
Given a Cygwin executable, how do i find out all the dll's that it depends upon?
For the libraries that are loaded by the system executable loader i can use a tool like depends (aka Dependency Walker), but i have no idea how to trace the dll's that the program tries to load dynamically with Load Library.
My aim is to be able to take the minimal dependencies of a program built for Cygwin platform in order to make it work portable, without all the Cygwin stuff that it is never gonna use (some base command line utils, man pages etc.).
Any help is appreciated!
Thanks to Michael Lockhart, the solution is simply to cygcheck the executable. Here are some references: on Wordpress and his site.