Fatal error png h no such file or directory

I am trying to run this in linux ubuntu. When I type make it says rgb_image.cc:26:24: fatal error: libpng/png.h: No such file or directory #include Then i followed this to

I am trying to run this in linux ubuntu. When I type make it says

rgb_image.cc:26:24: fatal error: libpng/png.h: No such file or directory
 #include <libpng/png.h>

Then i followed this to install png.h.

sudo install libpng-dev

But now its telling me

install: missing destination file operand after ‘libpng-dev’

What do I do?

Please help, thanks.

J. Chomel's user avatar

J. Chomel

8,04915 gold badges42 silver badges67 bronze badges

asked Apr 17, 2016 at 9:13

Alex winkler's user avatar

try rather this:

sudo apt-get install libpng-dev

Then maybe go askubuntu.com ;)

answered Apr 17, 2016 at 9:25

J. Chomel's user avatar

J. ChomelJ. Chomel

8,04915 gold badges42 silver badges67 bronze badges

For centOS 7 you can try

yum -y install libpng* 

answered Apr 11, 2018 at 21:10

Dev's user avatar

DevDev

3712 silver badges6 bronze badges

With Ubuntu 18, /usr/include/png.h moved to /usr/include/libpng/png.h
A workaround is this:
ln -s /usr/include/libpng/png.h /usr/include/png.h

Or you can configure your build to use include directory /usr/include/libpng

answered Jul 2, 2019 at 22:43

Dan Anderson's user avatar

Dan AndersonDan Anderson

2,2551 gold badge8 silver badges20 bronze badges

For Centos 8, I got the below warning message :

Warning: Header file <png.h> not found.
This host has no libpng library.
Disabling support for PNG framebuffers.

and I solved it using the command :

sudo yum install libpng-devel

answered Apr 23, 2021 at 6:02

harbinger's user avatar

harbingerharbinger

491 silver badge4 bronze badges

For Centos 7 use below

  • libpng-devel : Development tools for programs to manipulate PNG image format files

    yum install libpng-devel
    

J. Chomel's user avatar

J. Chomel

8,04915 gold badges42 silver badges67 bronze badges

answered Jun 30, 2018 at 8:43

sureshbabu kasthuri's user avatar

1

outoftime

║XLR8║

1212 / 909 / 270

Регистрация: 25.07.2009

Сообщений: 4,361

Записей в блоге: 5

1

29.12.2013, 00:09. Показов 3951. Ответов 8

Метки нет (Все метки)


Беда (: Вообщем есть проект на Qt и хочу сделать общие алгоритмы обработки изображений используя boost::gil. Приведу код:

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <QHBoxLayout>
#include <QLabel>
#include <QImage>
#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/png_dynamic_io.hpp>
// еще куча всего
// и далее важная часть
static void x_gradient_qt(const boost::gil::gray8c_view_t &src, boost::gil::gray8s_view_t const &dst)
{
    for (int y = 0; y != src.height(); ++y)
        for (int x = 1; x + 1 != src.width(); ++x)
            dst(x, y) = (src(x - 1, y) - src(x + 1, y)) / 2;
}
 
template<typename T = QWidget>
static std::unique_ptr<T> view_image_pair(QImage const &src, QImage &dst)
{
    std::unique_ptr<T> window(new T);
    QHBoxLayout *layout = new QHBoxLayout(window.get());
 
    QLabel *src_label;
    layout->addWidget(src_label = new QLabel);
    src_label->setPixmap(QPixmap::fromImage(src));
 
    QLabel *dst_label;
    layout->addWidget(dst_label = new QLabel);
    dst_label->setPixmap(QPixmap::fromImage(dst));
 
    return std::move(window);
}
// button click handler
void MainWindow::on_pushButton_clicked()
{
    QImage src(ui->lineEdit->text());
    QImage dst(src.size(), src.format());
 
    std::unique_ptr<QWidget> window = view_image_pair(src, dst);
    x_gradient_qt(src, dst);
 
    window->show();
}

В данном примере я пытаюсь собрать алгоритм вычисления тривиального градиента (код позаимствовал с официального сайта) и показать его в дополнительного окошка.

Собираю проект на Qt Creator + MinGW 4.8.1 и получаю следующий лог ошибок:

Bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
C:/Qt/Qt5.1.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/Work/www.freelancer.com/Implement an algorithmus for Image Processing/src/build'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..ImageHandler -I"C:boost_1_55_0" -I"C:QtQt5.1.15.1.1mingw48_32include" -I"C:QtQt5.1.15.1.1mingw48_32includeQtWidgets" -I"C:QtQt5.1.15.1.1mingw48_32includeQtGui" -I"C:QtQt5.1.15.1.1mingw48_32includeQtCore" -I"release" -I"." -I"." -I"C:QtQt5.1.15.1.1mingw48_32mkspecswin32-g++" -o releasemainwindow.o ..ImageHandlermainwindow.cpp
In file included from C:boost_1_55_0/boost/gil/extension/io/png_dynamic_io.hpp:37:0,
                 from ..ImageHandlermainwindow.cpp:8:
C:boost_1_55_0/boost/gil/extension/io/png_io.hpp:35:17: fatal error: png.h: No such file or directory
 #include "png.h"
                 ^
Makefile.Release:1109: recipe for target 'release/mainwindow.o' failed
mingw32-make[1]: Leaving directory 'D:/Work/www.freelancer.com/Implement an algorithmus for Image Processing/src/build'
makefile:34: recipe for target 'release' failed
compilation terminated.
mingw32-make[1]: *** [release/mainwindow.o] Error 1
mingw32-make: *** [release] Error 2
21:53:45: The process "C:QtQt5.1.1Toolsmingw48_32binmingw32-make.exe" exited with code 2.
Error while building/deploying project ImageHandler (kit: MinGW)
When executing step 'Make'

Добавлено через 9 минут
Да, приведу кусок кода с заголовочного файла png_io.hpp

C++
1
2
3
extern "C" {
#include "png.h"
}

Далее захожу в папку C:boost_1_55_0/boost/gil/extension/io/ и вижу что я не вижу там заголовочного файла «png.h» хотя я скачал и разархивировал boost как было сказано в гайде по установке.



0



DU

1499 / 1145 / 165

Регистрация: 05.12.2011

Сообщений: 2,279

29.12.2013, 00:13

2

загляните в png_io.hpp:

C++
1
2
3
4
5
6
7
8
9
10
11
...
 
#ifndef GIL_PNG_IO_H
#define GIL_PNG_IO_H
 
/// file
/// brief  Support for reading and writing PNG files
///         Requires libpng and zlib!
//
 
...

это отдельные сторонние либы, которые должны быть приделаны к проекту.



1



║XLR8║

1212 / 909 / 270

Регистрация: 25.07.2009

Сообщений: 4,361

Записей в блоге: 5

29.12.2013, 00:24

 [ТС]

3

DU, А можно еще пару слов о том что это за либы и где их искать?

Добавлено через 1 минуту
http://www.libpng.org/pub/png/libpng.html я так понимаю это libpng



0



1499 / 1145 / 165

Регистрация: 05.12.2011

Сообщений: 2,279

29.12.2013, 00:29

4

да, оно. libpng требует zlib и там на сайте есть ссылка на zlib:
http://www.zlib.net/



1



║XLR8║

1212 / 909 / 270

Регистрация: 25.07.2009

Сообщений: 4,361

Записей в блоге: 5

29.12.2013, 01:24

 [ТС]

5

http://tjaden.strangesoft.net/loadpng/mingw.html нашел я такую вот фишку для того что-бы быстро поставить себе обе библиотеки.
Когда архивы распаковались есть .dll файлы в папке bin, .lib.a.lib в папке lib и хедеры в include.

Теперь вопрос: куда это все распихать? Если я верно понимаю их содержимое нужно скинуть в корень MinGW что-бы компилятор смог их найти.



0



1499 / 1145 / 165

Регистрация: 05.12.2011

Сообщений: 2,279

29.12.2013, 01:50

6

ну да. прописать в проекте пути до новых инклудов так, чтобы при сборке, когда в исходниках
встретится «#include <png.h>» компилятор искал эти инклуды еще и по указанным путям. он их там
найдет и все будет хорошо.



1



║XLR8║

1212 / 909 / 270

Регистрация: 25.07.2009

Сообщений: 4,361

Записей в блоге: 5

29.12.2013, 02:17

 [ТС]

7

DU,

Цитата
Сообщение от outoftime
Посмотреть сообщение

extern «C» {
#include «png.h»
}

Там относительный путь, если я правильно помню то при относительном пути компилятор сначала ищет локальный файл а потом файл с этим названием в путях по умолчанию.

Собственно вопрос о том где компилятор будет искать эти файлы по умолчанию, что-бы можно было не трогать конфигурацию проекта.



0



1499 / 1145 / 165

Регистрация: 05.12.2011

Сообщений: 2,279

29.12.2013, 02:29

8

не работаю с креатором. вот тут вроде что-то есть:
http://qt-project.org/doc/qtcr… aries.html

самое простое в pro файле попробоват написать:
INCLUDEPATH += <your path>



1



outoftime

║XLR8║

1212 / 909 / 270

Регистрация: 25.07.2009

Сообщений: 4,361

Записей в блоге: 5

29.12.2013, 14:25

 [ТС]

9

DU, Закинул zlib & libpng хедеры в boostgilextensionio , папку библиотек добавил в проект, теперь новый лог ошибок

Bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o releaseImageHandler.exe release/main.o release/mainwindow.o release/moc_mainwindow.o  -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -LC:boost_1_55_0lib -LC:QtQt5.1.15.1.1mingw48_32lib -lQt5Widgets -lQt5Gui -lQt5Core 
release/mainwindow.o:mainwindow.cpp:(.text+0x2a1): undefined reference to `png_set_IHDR'
release/mainwindow.o:mainwindow.cpp:(.text+0x2b5): undefined reference to `png_write_info'
release/mainwindow.o:mainwindow.cpp:(.text+0x31c): undefined reference to `png_write_row'
release/mainwindow.o:mainwindow.cpp:(.text+0x33d): undefined reference to `png_write_end'
release/mainwindow.o:mainwindow.cpp:(.text+0x35d): undefined reference to `png_destroy_write_struct'
Makefile.Release:80: recipe for target 'releaseImageHandler.exe' failed
c:/qt/qt5.1.1/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: release/mainwindow.o: bad reloc address 0x2 in section `.text$_ZN5boost6detail15sp_counted_baseD1Ev[__ZN5boost6detail15sp_counted_baseD1Ev]'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [releaseImageHandler.exe] Error 1
mingw32-make[1]: Leaving directory 'D:/Work/www.freelancer.com/Implement an algorithmus for Image Processing/src/build'
makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
11:12:53: The process "C:QtQt5.1.1Toolsmingw48_32binmingw32-make.exe" exited with code 2.
Error while building/deploying project ImageHandler (kit: MinGW)
When executing step 'Make'

Кажется когда используешь библиотеку libpng надо явно указать компилятору о том что ты ее используешь а в строке 1 ее нет, проблема в этом?

Добавлено через 1 час 8 минут
Добавил 2 флага для линковки библиотек

Bash
1
LIBS += -lz -lpng -ljpeg

На примере

C++
1
2
3
4
5
6
    using namespace boost::gil;
 
    rgb8_image_t img(512, 512);
    rgb8_pixel_t red(255, 0, 0);
    fill_pixels(view(img), red);
    png_write_view("redsquare.png", const_view(img));

Работает.



0



dlib C++ Library

  • Summary

  • Files

  • Reviews

  • Support

  • Mailing Lists

  • Tickets ▾

    • Bugs
    • Patches
    • Feature Requests
  • News

  • Discussion

  • Wiki

Menu

LIBJPEG & LIBPNG not working


Created:

2015-03-20

Updated:

2015-03-26

  • Miguel Larios

    Hi,

    I’m trying to use libjpeg and libpng for a project about image recognition. The problem is that I’ve tried everything I’ve read in this forum to succesfully link libjpeg and libpng but it doesn’t work.

    I have already uncommented

    #define DLIB_JPEG_SUPPORT

    #define DLIB_PNG_SUPPORT

    but when I try to compile using Linux Mint and Terminal

    g++ -03 -I.. dlib/all/source.cpp -lpthread -lX11 lbp.cpp -o lbp

    I get this error

    In file included from dlib/all/source.cpp:54:0:dlib/all/../image_loader/png_loader.cpp:13:17: fatal error: png.h: No such file or directory

    include <png.h>

    compilation terminated

    What should I do to fix this?

     

    Last edit: Miguel Larios 2015-03-20

    • Davis

      • Miguel Larios

        When I did

        cmake ..

        I got this

        miguel@miguel-VirtualBox ~/Downloads/dlib-18.13/examples/build $ cmake ..
        — The C compiler identification is GNU 4.8.2
        — The CXX compiler identification is GNU 4.8.2
        — Check for working C compiler: /usr/bin/cc
        — Check for working C compiler: /usr/bin/cc — works
        — Detecting C compiler ABI info
        — Detecting C compiler ABI info — done
        — Check for working CXX compiler: /usr/bin/c++
        — Check for working CXX compiler: /usr/bin/c++ — works
        — Detecting CXX compiler ABI info
        — Detecting CXX compiler ABI info — done
        — Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so
        — Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so — found
        — Looking for gethostbyname
        — Looking for gethostbyname — found
        — Looking for connect
        — Looking for connect — found
        — Looking for remove
        — Looking for remove — found
        — Looking for shmat
        — Looking for shmat — found
        — Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
        — Looking for png_create_read_struct
        — Looking for png_create_read_struct — not found
        — Looking for jpeg_read_header
        — Looking for jpeg_read_header — not found
        — Searching for BLAS and LAPACK
        — Looking for sys/types.h
        — Looking for sys/types.h — found
        — Looking for stdint.h
        — Looking for stdint.h — found
        — Looking for stddef.h
        — Looking for stddef.h — found
        — Check size of void*
        CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
        Please set them or make sure they are set and tested correctly in the CMake files:
        JPEG_LIBRARY
        linked by target «cmTryCompileExec385043375» in directory /home/miguel/Downloads/dlib-18.13/examples/build/CMakeFiles/CMakeTmp

        CMake Error: Internal CMake error, TryCompile configure of cmake failed
        — Check size of void* — failed


        No BLAS library found so using dlib’s built in BLAS. However, if you
        install an optimized BLAS such as OpenBLAS or the Intel MKL your code
        will run faster. On Ubuntu you can install OpenBLAS by executing:
        sudo apt-get install libopenblas-dev liblapack-dev
        Or you can easily install OpenBLAS from source by downloading the
        source tar file from http://www.openblas.net, extracting it, and
        running:
        make; sudo make install
        ***********
        — Check for STD namespace
        — Check for STD namespace — found
        — Looking for C++ include iostream
        — Looking for C++ include iostream — found
        CMake Warning at CMakeLists.txt:115 (find_package):
        By not providing «FindOpenCV.cmake» in CMAKE_MODULE_PATH this project has
        asked CMake to find a package configuration file provided by «OpenCV», but
        CMake did not find one.

        Could not find a package configuration file provided by «OpenCV» with any
        of the following names:

        OpenCVConfig.cmake
        opencv-config.cmake
        

        Add the installation prefix of «OpenCV» to CMAKE_PREFIX_PATH or set
        «OpenCV_DIR» to a directory containing one of the above files. If «OpenCV»
        provides a separate development package or SDK, be sure it has been
        installed.

        — Configuring incomplete, errors occurred!
        See also «/home/miguel/Downloads/dlib-18.13/examples/build/CMakeFiles/CMakeOutput.log».
        See also «/home/miguel/Downloads/dlib-18.13/examples/build/CMakeFiles/CMakeError.log».

         

        Last edit: Miguel Larios 2015-03-22

        • Davis

          Try using the new version of dlib. I think that will fix the error.

          • Miguel Larios

            It worked but since I’m not familiar with the use of CMake, how should I compile my file? It compiles the examples but how do I try it with my program? Sorry for such a noob question.

            • Davis

              If you look at the examples/CMakeLists.txt file it should be clear how to
              edit it to accomplish what you want. It contains comments that explain
              what to do.

              • Miguel Larios

                When I compiled my program it throws a lot of warnings, I put my program in folder examples and simply added addexample(lbp) which is the name of my file. But in compiling process it throws A LOT of warnings about redefinitions of DLIB_JPEG_SUPPORT and DLIB_PNG_SUPPORT

                What should I do?

                 

                Last edit: Miguel Larios 2015-03-24

                • Davis

                  Beats me :) You have to fix the errors in your program.

                  • Miguel Larios

                    Thank you for your help. I’m having another issue, I’m trying to create a subimage of an image. So im doing this:

                    rectangle rect(left, top, right, bottom); //left, top, right, bottom are values

                    const_sub_image_proxy< array2d<int> > temp(img, rect);

                    and then I return temp from a function. But apparently when I do

                    const_sub_image_proxy< array2d<int> > head = getHead(points[0]); //funcion where I return temp

                    save_bmp(head, «foo.bmp»);

                    I doesn’t save the image, just 1 pixel. And I thought I was doing something wrong, I use gdb to debug my program and I found this:

                    56 const_sub_image_proxy< array2d<int> > temp(img, rect);

                    (gdb) print rect

                    $9 = {l = 66, t = 73, r = 98, b = 41}

                    (gdb) next

                    57 return temp;

                    (gdb) print temp

                    $10 = {_data = 0x7bcc4c, _width_step = 644, _nr = 0, _nc = 0}

                    It creates the rectangle well, but temp is created with size 0 0.

                    How can I fix this?

                    EDIT: Forget it, I found my mistake. I was calculating top and bottom wrong.

                     

                    Last edit: Miguel Larios 2015-03-26

                    • Davis

                      A sub_image is only valid as long as the original image exists. So you
                      can’t return it from a function if the img is local to that function.
                      Also, the code is a lot easier to read if you call sub_image(img,rect)
                      instead of writing out everything.

                      Cheers,
                      Davis

                      On Thu, Mar 26, 2015 at 11:56 AM, Miguel Larios mikj13@users.sf.net wrote:

                      Thank you for your help. I’m having another issue, I’m trying to create a
                      subimage of an image. So im doing this:

                      rectangle rect(left, top, right, bottom); //left, top, right, bottom are

                      values

                      const_sub_image_proxy< array2d<int> > temp(img, rect);

                      and then I return temp from a function. But apparently when I do

                      const_sub_image_proxy< array2d<int> > head = getHead(points[0]);

                      //funcion where I return temp

                      save_bmp(head, «foo.bmp»);

                      I doesn’t save the image, just 1 pixel. And I thought I was doing
                      something wrong, I use gdb to debug my program and I found this:

                      56 const_sub_image_proxy< array2d<int> > temp(img, rect);

                      (gdb) print rect

                      $9 = {l = 66, t = 73, r = 98, b = 41}

                      (gdb) next

                      57 return temp;

                      (gdb) print temp

                      $10 = {_data = 0x7bcc4c, _width_step = 644, _nr = 0, _nc = 0}

                      It creates the rectangle well, but temp is created with size 0 0.

                      How can I fix this?


                      LIBJPEG & LIBPNG not working


                      Sent from sourceforge.net because you indicated interest in <
                      https://sourceforge.net/p/dclib/discussion/442518/>

                      To unsubscribe from further messages, please visit <
                      https://sourceforge.net/auth/subscriptions/>


Log in to post a comment.


View Full Version : [ubuntu] Error when running «make»


cats4gold

November 20th, 2010, 04:13 AM

Today, I was trying to compile and install a minecraft mapper with the program «make». I navigated to the directory in terminal and ran make. It found the make file and begins to work, then spits an error and stops. To be specific, this was the error:

cats4gold@computer:~/Downloads/cartograph-linux$ make
make -C src/
make[1]: Entering directory `/home/cats4gold/Downloads/cartograph-linux/src’
g++ -c -pipe -O2 -Wall main.cpp -o main.o
In file included from main.cpp:16:
Level.h:8: fatal error: zlib.h: No such file or directory
compilation terminated.
make[1]: *** [main.o] Error 1
make[1]: Leaving directory `/home/cats4gold/Downloads/cartograph-linux/src’
make: *** [default] Error 2
cats4gold@computer:~/Downloads/cartograph-linux$

It just looks like a missing directory, but I was just making sure this was all. Thanks in advance.


mr_luksom

November 20th, 2010, 04:20 AM

Have you got the ‘build-essential’ package?

sudo apt-get install build-essential

You should have this before compiling.


SeijiSensei

November 20th, 2010, 04:21 AM

No, it can’t find the zlib.h header file; zlib provides support for the gzip compression algorithm.

I’m going to guess that you don’t have the kernel-headers installed; that’s where zlib.h lives in my installation. The package name depends on your version of Ubuntu. Try running «dpkg -s linux-headers-$(uname -r)» to see if you have the headers installed. If not, then use «sudo apt-get install linux-headers-$(uname -r)» to get them.


cats4gold

November 20th, 2010, 04:23 AM

No, it can’t find the zlib.h header file; zlib provides support for the gzip compression algorithm.

I’m going to guess that you don’t have the kernel-headers installed; that’s where zlib.h lives in my installation. The package name depends on your version of Ubuntu. Try running «dpkg -s linux-headers-$(uname -r)» to see if you have the headers installed. If not, then use «sudo apt-get install linux-headers-$(uname -r)» to get them.Status: install ok installed

Have you got the ‘build-essential’ package?

sudo apt-get install build-essential

You should have this before compiling.
build-essential is already the newest version.


cats4gold

November 20th, 2010, 04:43 AM

No, it can’t find the zlib.h header file; zlib provides support for the gzip compression algorithm.

I’m going to guess that you don’t have the kernel-headers installed; that’s where zlib.h lives in my installation. The package name depends on your version of Ubuntu. Try running «dpkg -s linux-headers-$(uname -r)» to see if you have the headers installed. If not, then use «sudo apt-get install linux-headers-$(uname -r)» to get them.
Actually, it appears they weren’t installed, or at least needed to be updated. No effect, though.


SeijiSensei

November 20th, 2010, 05:00 AM

http://manpages.ubuntu.com/manpages/maverick/man3/zlib.3.html


mc4man

November 20th, 2010, 05:50 AM

Do you have zlib1g-dev installed?

Edit: if not then install the ubuntu package, (sudo apt-get install zlib1g-dev ), do not do as this fellow (built and installed zlib source
http://ubuntuforums.org/showthread.php?p=10121928#post10121928


cats4gold

November 20th, 2010, 06:02 AM

Do you have zlib1g-dev installed?

Edit: if not then install the ubuntu package, (sudo apt-get install zlib1g-dev ), do not do as this fellow (built and installed zlib source
http://ubuntuforums.org/showthread.php?p=10121928#post10121928
Thanks! That solves one problem, but leads to another error:

cats4gold@computer:~/Downloads/cartograph-linux$ make
make -C src/
make[1]: Entering directory `/home/cats4gold/Downloads/cartograph-linux/src’
g++ -c -pipe -O2 -Wall main.cpp -o main.o
g++ -c -pipe -O2 -Wall Level.cpp -o Level.o
Level.cpp:2: fatal error: png.h: No such file or directory
compilation terminated.
make[1]: *** [Level.o] Error 1
make[1]: Leaving directory `/home/cats4gold/Downloads/cartograph-linux/src’
make: *** [default] Error 2
cats4gold@computer:~/Downloads/cartograph-linux$

Same thing, different missing file.


mc4man

November 20th, 2010, 06:29 AM

What you can do is search here for the file and ck. the results (scroll down to «Search the contents of packages»
Make sure you set to search the ubuntu release you’re using,
http://packages.ubuntu.com/
Ex.
these are the results on maverick for png.h
http://packages.ubuntu.com/search?searchon=contents&keywords=png.h&mode=exactfilename&suite=maverick&arch=any

So I’d take a guess and install ‘libpng12-dev’

Edit: which mapper are you trying to build?


cats4gold

November 20th, 2010, 04:15 PM

What you can do is search here for the file and ck. the results (scroll down to «Search the contents of packages»
Make sure you set to search the ubuntu release you’re using,
http://packages.ubuntu.com/
Ex.
these are the results on maverick for png.h
http://packages.ubuntu.com/search?searchon=contents&keywords=png.h&mode=exactfilename&suite=maverick&arch=any

So I’d take a guess and install ‘libpng12-dev’

Edit: which mapper are you trying to build?
I’ll take a look at these, thanks!

Also, I’m working on cartograph.


cats4gold

November 20th, 2010, 07:39 PM

Make ran succesfully and placed an executable in the folder named «cartograph»

When I right click and press open; no response. Do I need to open it from the terminal?


cats4gold

November 20th, 2010, 07:44 PM

Yes, I did. Okay, problem solved. Thanks everyone!


Powered by vBulletin® Version 4.2.2 Copyright © 2023 vBulletin Solutions, Inc. All rights reserved.

Я работаю над проектом, который требует от меня использования CImg, который, в свою очередь, требует libpng. Я использую CLion и cmake с MinGW-W64 GCC-8.1.0. Я следил за этим ответом — https://stackoverflow.com/a/41956016/11382155, чтобы настроить его.

Так выглядит мой CMakeLists.txt

cmake_minimum_required(VERSION 3.15)
project(CImgProject)

set(CMAKE_CXX_STANDARD 14)

set(SOURCE_FILES main.cpp)
add_executable(CImgProject ${SOURCE_FILES})

# You can alter these according to your needs, e.g if you don't need to display images - set(YOU_NEED_X11 0)
set(YOU_NEED_X11 1)
set(YOU_NEED_PNG 1)

if(${YOU_NEED_X11} EQUAL 1)
    message(STATUS "Looking for X11...")
    find_package(X11 REQUIRED)
    include_directories(${X11_INCLUDE_DIR})
    target_link_libraries(CImgProject ${X11_LIBRARIES})
else()
    target_compile_definitions(CImgProject PRIVATE cimg_display=0)
endif()

if(${YOU_NEED_PNG} EQUAL 1)
    message(STATUS "Looking for libpng...")
    set(ZLIB_ROOT "CImg283/zlib-1.2.11")
    set(ZLIB_LIBRARY "CImg283/zlib-1.2.11")
    set(PNG_ROOT "CImg283/lpng1637")
    set(PNG_LIBRARY "CImg283/lpng1637")
    find_package(PNG REQUIRED)
    include_directories(${PNG_INCLUDE_DIR})
    target_link_libraries (CImgProject ${PNG_LIBRARY})
    target_compile_definitions(CImgProject PRIVATE cimg_use_png=1)
endif()

Это мой main.cpp

#include "CImg283/CImg.h"

using namespace cimg_library;

int main() {
    CImg<unsigned char> img(640,400,1,3);         // Define a 640x400 color image with 8 bits per color component.
    img.fill(0);                                  // Set pixel values to 0 (color : black)
    unsigned char purple[] = { 255,0,255 };       // Define a purple color
    img.draw_text(100,100,"Hello World",purple);  // Draw a purple "Hello world" at coordinates (100,100).
    img.display("Window Title");                  // Display the image in a display window.
    img.save_png("test.png");                     // Save as PNG to prove we linked correctly
    return 0;
}

У меня проблема в том, что когда я нажимаю build, я получаю следующую ошибку

====================[ Build | CImgProject | Debug ]=============================
"C:Program FilesJetBrainsCLion 2019.1bincmakewinbincmake.exe" --build C:UsersbhaveOneDriveDesktopuntitledcmake-build-debug --target CImgProject -- -j 6
Scanning dependencies of target CImgProject
[ 50%] Building CXX object CMakeFiles/CImgProject.dir/main.cpp.obj
In file included from C:UsersbhaveOneDriveDesktopuntitledmain.cpp:3:
C:UsersbhaveOneDriveDesktopuntitledCImg283/CImg.h:447:10: fatal error: png.h: No such file or directory
 #include "png.h"
          ^~~~~~~
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFilesCImgProject.dirbuild.make:63: CMakeFiles/CImgProject.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFilesMakefile2:75: CMakeFiles/CImgProject.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFilesMakefile2:82: CMakeFiles/CImgProject.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: CImgProject] Error 2

Я не знаю, почему эта ошибка появляется, когда cmake может найти libpng, и я проверил, что png.h определенно существует.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal error pitches h no such file or directory compilation terminated
  • Fatal error php пример
  • Fatal error php перехват
  • Fatal error permission denied
  • Fatal error pe035

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии