libpng error undefined symbol png_read_image in unix - c++

libpng error undefined symbol png_read_image in unix
i'm developing a program with C language in unix sco open server 5.0.7
and now, i need to use libpng in my project to load a png file
when i include in my code (png.h and code are in same directory) and compile program there was no error.
but when i use png.h methods such as png_read_image or png_sig_cmp and compile it, compiler send me error:
undefined symbol png_read_image
amd other
can anybody help me?

You need to include add library for compiling.
Example: gcc -static myfile.c -L/user/local/lib -lmath -o execfile
See the gcc syntax at http://www.rapidtables.com/code/linux/gcc.htm

Related

How can I fix my OpenGL build environment on OSX?

UPDATE
I've sorted this by explicitly adding the appropriate -I and -L options, but I'm curious as to why this is necessary now when it wasn't before? On the plus side those annoying library out-of-sync warnings are gone.
UPDATE ENDS
I've broken my OSX OpenGL build environment. I'm building from terminal (using make) with g++, for example:
g++ -o myprog main.o -lglfw -lglew -framework OpenGL
and getting errors:
ld: library not found for -lglfw clang: error: linker command failed with exit code 1 (use -v to see invocation)
These are in addition to compiler errors such as:
g++ -c main.cpp main.cpp:3:10: fatal error: 'GL/glew.h' file not found
So it seems the OpenGL libraries and includes have been lost. Everything was working fine until I executed the command:
export SDKROOT="$(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
Which I did to try and fix warning messages like:
ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
I got that 'fix' from here: macOS framework lib problem
I realise it was reckless running commands that I don't fully understand but nonetheless... now I can't compile/link any OpenGL code and after scouring the internet for help I've come up with nothing, so here I am.
I'm running OSX 10.13.6 on a 2013 MacBook Pro.
First post BTW so please forgive me if I've not provided enough detail.

MinGW, linking to a dll on Windows

I'm trying to use a library I received from a camera vendor in a sample program. I have a .dll and a .lib file for the library. My compile command is:
g++ -o "Win32App.exe" -L"..\..\SK develop\SK91GigE-WIN\Lib" obj/winmain.o obj/callbacks.o obj/resource.o -s -lcomctl32 -Wl,--subsystem,windows -lSK91GigE_x64
and I get:
obj/winmain.o:winmain.cpp:(.text+0x292): undefined reference to `SK_LOADDLL'
collect2.exe: error: ld returned 1 exit status
having a look on the .lib with nm shows:
BFD: SK91GigE_x64.lib(SK91GigE_x64.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
nm: SK91GigE_x64.dll: File format not recognized
and for the dll it outputs:
nm: SK91GigE_x64.dll: File format not recognized
Any ideas how I can modify that lib to include it?
windows path variable pointed to 32 bit MinGW. setting the path to the 64bit version of MinGW solved the problem. I didn't check that

How do I link the static Stasm library to my program?

Earlier I succesfully compiled Stasm using cmake on Ubuntu 13.10. It gave me the static library libstasm.a.
However, I'm trying to build my own program using Stasm code but every time I try g++ gives me this:
hanna#hanna-HP-650-Notebook-PC:~/Desktop$ g++ -Wall -L/home/hanna/Downloads/stasm4.1.0/build -lstasm stasmtest.cpp -o stasmtest
stasmtest.cpp:7:23: fatal error: stasm_lib.h: No such file or directory
#include "stasm_lib.h"
^
compilation terminated.
I tried compiling the Minimal.cpp example in the external library because that is supposed to show how to use Stasm in my own programs but still I get the same error.
Can someone please tell me what command I should use to link the Stasm library to my program?
Thanks in advance!
You get a compilation error, not a linking one. g++ cannot find the "stasm_lib.h" header. Use -I/path/to/stasm_lib.h as parameter to g++.

FLTK g++ Compile error

I have an FLTK project that I finished in visual studios and it compiles absolutely fine. But when I use g++ to compile it it gives me this error:
Undefined first referenced
symbol in file
_ZN4ROMS9ROMS_Menu24read_recipes_ingredientsE6String /var/tmp//ccWVvonz.o
_ZN4ROMS9ROMS_Menu12read_catprdsE6String /var/tmp//ccWVvonz.o
_ZN4ROMS9ROMS_Menu11Read_ordersE6String /var/tmp//ccWVvonz.o
ld: fatal: Symbol referencing errors. No output written to a.out
I'm using a shell file with the following instructions to compile my project:
/opt/csw/gcc4/bin/g++ -Wno-deprecated -I/opt/csg/include main.cpp Graph.cpp GUI.cpp
Window.cpp -L/opt/csw/gcc4/lib/libstdc++.a:/opt/csg/lib -lX11
/opt/csw/lib/libjpeg.so.62 /opt/csg/lib/libfltk.a /opt/csg/lib/libfltk_images.a
Again compiles fine in VS but problems in g++. I don't even understand the error, any help is appreciated, thanks. Will post any code if needed.
Undefined symbol means that you compiled by referencing a declaration, but the linker could not find the definition.
I'm not entirely sure what I'm looking at either from the message. Either you are missing the symbols in ROMS or that is where they were referenced.
_ZN4ROMS9ROMS_Menu24read_recipes_ingredientsE6String
Guessing at the demangling...
ROMS::ROMS_Menu::read_recipes_ingredients::String
You may not have included a file?

GCC - Linking bass.lib on Ubuntu

I wrote an application on Windows using CPP and BASS, and now I have to get it running on Linux (UBUNTU).
I am using gcc version 4.5.2.
I have bass.lib in my directory from which I try to compile prog.cpp using the following command arguments:
gcc prog.cpp -L. -lbass.lib
But I get the following error:
/usr/bin/ld: cannot find -lbass.lib
collect2: ld returned 1 exit status
I figure that this is a linking error, the compiler is not finding Bass.lib but I have specified as an argument on the command line.
Not sure what to do, any help would be really great.
bass.lib sounds like the windows library. You cannot use libraries generated on windows, (likely generated with the MSVC compiler), on linux.
The linux version of the library seems to be named libbass.so , in which case you'd use -lbass as the linker argument , and possibly other compiler/linker flags as well depending on where on the system you install the library. The bass.txt in the linux download of libbass have a few notes on what to do on Linux.