How do I install libuuid with Homebrew on MacOS 11.1? - c

I'm aware there is a macports libuuid package, however AFAIK it's not safe to use homebrew and macports on the same machine.
This answer seems outdated. I say that because when I use brew install ossp-uuid make doesn't like it, despite seeming to find uuid.h.
What is the current and up to date homebrew package to install libuuid on mac?
Alternatively, could one build libuuid from source and if yes, how?

I was made aware that libuuid is already part of macOS.
It was therefore enough to just add an OS specific include.
#if __APPLE__
#include <uuid/uuid.h>
#else
#include <uuid.h>
#endif

I was porting an app from Linux to MacOS Monterey (could apply to 11.1 (Big Sur) as well).
The link was failing on libuuid, even though it compiled ok as on Linux.
I finally got my build to link, having 'homebrew install'ed ossp-uuid with homebrew version 3.6.4, under Monterey (12.5.1).
I first heard of ossp-uuid in this thread (thanks blkpingu).
I had tried several things before. It compiled ok, but did not link. brew install ossp-uuid fixed that (homebrew 3.6.4), and brew set up the requisite links to find the library under /usr/local/lib .
I left the source code as #include <uuid/uuid.h>, in this particular case.

Related

In C, how do I install GL/glx.h , GL/gl.h and GL/glu.h on Mac OS

I have some code which includes the headers GL/glx.h , GL/gl.h and GL/glu.h . I do not even know what these are, and Google is not a lot of help because there is so much noise in the search results. So (optionally) what are they, but more importantly, how do I install them on a Mac (Mac OS 10.15.4). I have installed other stuff using homebrew so that would be my preference.
EDIT: By renaming the headers to OpenGL/glx.h etc, I can now find gl.h abd glu.h but not glx.h.
This answer openGL glx.h missing form xcode 4 mac lion says "If you install XQuartz you get X11 which has glx.h" but this is not correct, at least not for me. I have installed xquartz using brew, but still cannot find glx.h.
Another site suggested installing Xcode, which I did, but that does not contain glx.h either.
Installing xquartz fixed it. OpenGL (at least the versions I found) is insufficient because it does not include glx.h. The page xquartz.org says, "The XQuartz project is an open-source effort to develop a version of the X.Org X Window System that runs on OS X. Together with supporting libraries and applications, it forms the X11.app that Apple shipped with OS X versions 10.5 through 10.7."
So I downloaded and installed xquartz, and then compiled with -I/opt/X11/include instead of -I/usr/X11R6/include, and linked with -L/opt/X11/lib instead of -L/usr/X11R6/lib; as suggested at fatal error 'GL/glx.h' file not found on mac after Xquartz is installed ; and it all worked.

simics installation libstdc++.so.6 version not found

I downloaded a tarball of simics from the web.
I tried to run the ./simics-gui
and I get this error
/home/leungtimothy/Desktop/simics/simics-4.0.60/amd64-linux/sys/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /usr/lib/x86_64-linux-gnu/libproxy.so.1)
Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgiolibproxy.so
I looked up a lot of posts, most of them are relate to linking problem. I am not able to find a libstdc++.so.6 on my 64 bits ubuntu v13.04 .
Any ideas about how to fix this?
Thank you so much
libstdc++ is the GNU Standard C++ library, which will be required by applications built with the GNU C++ compiler.
Evidently libstdc++6 is not installed on your system. It is typically installed by installing the GNU C++ compiler:
sudo apt-get install g++
If you don't need the compiler you can install libstdc++6 independently:
sudo apt-get install libstdc++6
I believe that Simics also ships with a few system libraries, that you can find in the installed base package (directory simics-<version>), at the path <host>/sys/lib/, where libstdc++.so.6 is one of them.
Looking at the path, it looks like it is Simics 4.0 which is over 8 years olds.
I suggest download and install the latest version of Simics from a proper source,
https://downloadcenter.intel.com/download/30403/Intel-Simics-Public-Release-Preview

(Mac OSX) Adding libraries to C -specifically gnuplot

I am a begineer trying to get code in C. I am working on a Mac and using xcode. My only past experience has been with java using eclipse and everything was pretty straight forward. I have almost no experience with terminal.
I am required to learn a bit of C for a project I will be working on and the learning of syntax is coming along okay, but I am at a point where I need to include some libraries in my c program. Specifically I am attempting to make plots with gnuplots.
I have downloaded gnuplot-4.6.3 from their repository and I do not even know how to install the files. I have been looking around and have tried using terminal to use the ./configure command when I am in the gnuplot-4.6.3 directory. But I really don't know what I am doing so I don't even know where to go next or what to do next.
Sorry if this is so trivial, I honestly just have never done this before and I cannot find a good tutorial on what to do.
Thanks for any help you can offer.
I would recommend using MacPorts for installing third-party tools and libraries. It knows the dependencies required and will install them as part of the installation.
Download it from macports.org.
Install it, and allow it to modify your ~/.profile so that /opt/local/bin is in your $PATH (any issue then just do export PATH=/opt/local/bin:$PATH from the command line).
sudo port selfupdate
sudo port install gnuplot
Now that will install the library into /opt/local/lib with the include files in /opt/local/include, so now just add that library to your Xcode project. Select the target and in the Build Phases tab open up the Link Binary With Libraries and press the + button and select Add Other. Now find /opt/local/lib/libgnuplot.a (I am assuming that's what it's called; I don't have it installed my self):
Now add /opt/local/include to your Header Search Paths so the compiler can find the gnuplot header files. Select the target and in Build Setting type in "header search" in the search box. Now double-click on the Header Search Path in the target column (or the project column to the right) and add /opt/local/include:
It's fine! You're learning then! Keep up! When I hit this kind of problem you may want to learn about the basis for linux gcc/g++ compilation and linking processes. Then you should learn Cmake and Automake, which are basically packages to configure projects before compiling building.
A typical (good) project in Unix systems build with commands
./configure
make
sudo make install
or
cmake CMakelists.txt
make all
sudo make install
That's what you need to do after downloading a source tarball online to install unix programs.
Now since you are using Mac, there are so-called package installers, one which is macports and homebrew. I personally suggest homebrew than macports here (I've tried both, although macports still outnumber homebrew with the number of repos, homebrew has the newest support, especially when upgrading to a new OS). So to install homebrew you can do
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Execute that in your terminal (see http://brew.sh/) for more information.
Then you could simply install GNUplot by
brew install gnuplot

How to set up libusb on Mac OS X?

I'd like to try to make a user-space device driver using libusb on Mac, but I'm confused where to start. In the SDK installer (which I got from http://www.ellert.se/twain-sane) it said something about examples which I couldn't find anywhere on my computer.
Could anyone please describe how do I set up libusb for development on OS X? May I use Xcode? What should I include in my code?
brew install libusb-compat
Working on OSX Yosemite 10.10
Easiest way to do this:
brew install libusb
Homebrew is amazing and I recommend it for all developers that use Mac.
I tried to install the SDK from the aforementioned website and couldn't find a trace of it once the installer finished. Though I did find some libusb items at /usr/local/Developer/SDKs/MacOSX10.6.sdk/usr/local/ I'm not sure it came from that installer as I couldn't find any examples, just libraries and they were labeled as libusb0.1.4.
On the other hand, since you asked your question with the macports tag, I'd suggest you use that to install libusb as it at least puts everything in a known location:
/opt/local/var/macports/software for install files
/opt/local/lib for libraries
/opt/local/include for header files
If you've never used macports then once you have macports installed then you can install libusb using
sudo port install libusb
to install libusb1.0 or
sudo port install libusb-legacy
to install libusb0.1.12.
Then you can create a project in Xcode and link to the libusb-*.a library contained in /opt/local/lib (in my directory my library file is called libusb-1.0.a since I have libusb1.0 installed).
I don't have much experience using Xcode so I can't help you any further down this path. Personally what I've done so far is use a Python wrapper called pyusb to do some quick experimentation with libusb as I don't have to do IDE setup or library/include file setup with Python.
UPDATE: Poking around the macports install directory for libusb, I didn't find any examples included which was a bummer. If you've gotten this far then I'd suggest going directly to the source for libusb, download and unpack the tar file, and building the code that's in the example directory. Sorry for the roundabout way of getting libusb examples but I've really come to appreciate the organization macports imposes on installations which saves me quite a bit of future pain (like when I want to uninstall).
once libusb is installed using following command:
brew install libusb
or
brew install libusb-compat
link libusb to the build system using
brew link libusb
to be able to configure any project depending on libusb, use pkg-config:
pkg-config --cflags libusb-1.0
and
pkg-config --libs libusb-1.0
before calling any ./configure

Question about Macports

I just got Macports installed on my mac, of which os version is Snow Leopard (10.6). I used Macports to install several packages through 'sudo port install' command, and all these packages are reported active after the installation. I just wonder that whether these packages are really working? For example, macports tells me that 'gcc44 #4.4.2_0 (active)', however in python it says '[GCC 4.0.1 (Apple Inc. build 5493)] on darwin'.
So I just want to know that if there is some problem with my method of installing or my macports needs some configuration after installation?
Any help is appreciated! I am really new in Mac OS.
I believe Python is declaring the version of gcc used to build it which should be the gcc installed on your Mac i.e. the version that came with the Mac OS Development tools. This should be located in /usr/bin/gcc.
You should find the gcc version matches when you execute
/usr/bin/gcc -v
I do not think anything is wrong with your setup or configuration. It just shows Python was compiled using the gcc provided by Apple
Macports installs software not to conflict with the versions provided by Apple. If they replaced the C compiler and libraries, really bad things might happen when Apple provided operating system updates.
gcc is the command for Apple's version of gcc, at /usr/bin and version 4.0.1 for Leopard.
gcc-mp-4.4 is the command for gcc version 4.4 as provided by MacPorts, located at /opt/local/bin.
Similarly there will be versions of python in /opt/local/bin.
Like houmam, I prefer to explicitly invoke versions by name. If you want to connect particular versions to python, I think that the MacPorts package python_select (this has now been replace by port select python) implements this by using symbolic links. I've never used it.
It probably is just that compiler that was picked by the build was that installed by XCode. You can try typing which gcc to see which one is in your path. The macports one would by default be in /opt/local somewhere.

Resources