LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
-
Hi,
I am trying to use third party PDF viewer library libmupdf compiled successfully in MS visual studio(32 bit), But I am facing issues when I am trying to build sample application in QT.LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
QT version : 5.9 community edition ( MSVC2015 32 bit compiler ).
mupdf version: mupdf-1.12.0-source.tar.gzhttps://mupdf.com/docs/index.html
#include <mupdf/fitz.h>
int main(int argc, char **argv)
{
char *input;
float zoom, rotate;
int page_number, page_count;
fz_context *ctx;
fz_document *doc;
fz_pixmap *pix;
fz_matrix ctm;
int x, y;if (argc < 3) { fprintf(stderr, "usage: example input-file page-number [ zoom [ rotate ] ]\n"); fprintf(stderr, "\tinput-file: path of PDF, XPS, CBZ or EPUB document to open\n"); fprintf(stderr, "\tPage numbering starts from one.\n"); fprintf(stderr, "\tZoom level is in percent (100 percent is 72 dpi).\n"); fprintf(stderr, "\tRotation is in degrees clockwise.\n"); return EXIT_FAILURE; } input = argv[1]; page_number = atoi(argv[2]) - 1; zoom = argc > 3 ? atof(argv[3]) : 100; rotate = argc > 4 ? atof(argv[4]) : 0; /* Create a context to hold the exception stack and various caches. */ ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED); if (!ctx) { fprintf(stderr, "cannot create mupdf context\n"); return EXIT_FAILURE; } /* Register the default file types to handle. */ fz_try(ctx) fz_register_document_handlers(ctx); fz_catch(ctx) { fprintf(stderr, "cannot register document handlers: %s\n", fz_caught_message(ctx)); fz_drop_context(ctx); return EXIT_FAILURE; } /* Open the document. */ fz_try(ctx) doc = fz_open_document(ctx, input); fz_catch(ctx) { fprintf(stderr, "cannot open document: %s\n", fz_caught_message(ctx)); fz_drop_context(ctx); return EXIT_FAILURE; } /* Count the number of pages. */ fz_try(ctx) page_count = fz_count_pages(ctx, doc); fz_catch(ctx) { fprintf(stderr, "cannot count number of pages: %s\n", fz_caught_message(ctx)); fz_drop_document(ctx, doc); fz_drop_context(ctx); return EXIT_FAILURE; } if (page_number < 0 || page_number >= page_count) { fprintf(stderr, "page number out of range: %d (page count %d)\n", page_number + 1, page_count); fz_drop_document(ctx, doc); fz_drop_context(ctx); return EXIT_FAILURE; } /* Compute a transformation matrix for the zoom and rotation desired. */ /* The default resolution without scaling is 72 dpi. */ fz_scale(&ctm, zoom / 100, zoom / 100); fz_pre_rotate(&ctm, rotate); /* Render page to an RGB pixmap. */ fz_try(ctx) pix = fz_new_pixmap_from_page_number(ctx, doc, page_number, &ctm, fz_device_rgb(ctx)); fz_catch(ctx) { fprintf(stderr, "cannot render page: %s\n", fz_caught_message(ctx)); fz_drop_document(ctx, doc); fz_drop_context(ctx); return EXIT_FAILURE; } /* Print image data in ascii PPM format. */ printf("P3\n"); printf("%d %d\n", pix->w, pix->h); printf("255\n"); for (y = 0; y < pix->h; ++y) { unsigned char *p = &pix->samples[y * pix->w * pix->n]; for (x = 0; x < pix->w; ++x) { if (x > 0) printf(" "); printf("%3d %3d %3d", p[0], p[1], p[2]); p += 4; } printf("\n"); } /* Clean up. */ fz_drop_pixmap(ctx, pix); fz_drop_document(ctx, doc); fz_drop_context(ctx); return EXIT_SUCCESS;
}
-
Now I am able to compile, I have to move my release lib to debug lib folder in order to deal with some link issues.
#-------------------------------------------------
Project created by QtCreator 2017-12-18T12:49:07
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = PdfViewer1
TEMPLATE = appThe following define makes your compiler emit warnings if you use
any feature of Qt which as been marked as deprecated (the exact warnings
depend on your compiler). Please consult the documentation of the
deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
You can also make your code fail to compile if you use deprecated APIs.
In order to do so, uncomment the following line.
You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cpp
mywidget.cppHEADERS +=
mywidget.hFORMS +=
mywidget.uiwin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/release/ -llibmupdf
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/debug/ -llibmupdfINCLUDEPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include
DEPENDPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/includewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/release/ -llibresources
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/debug/ -llibresourcesINCLUDEPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include
DEPENDPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/includewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/release/ -llibthirdparty
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/debug/ -llibthirdpartyINCLUDEPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include
DEPENDPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include -
@Aditya1309 This is a warning. Are there any errors? Is you app working?
-
Its not working, I am not able to get it compiled.
-
@Aditya1309 What other issues do you have? Because the one you posted is a warning, not an error.
Can you show your pro file? -
Now I am able to compile, I have to move my release lib to debug lib folder in order to deal with some link issues.
#-------------------------------------------------
Project created by QtCreator 2017-12-18T12:49:07
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = PdfViewer1
TEMPLATE = appThe following define makes your compiler emit warnings if you use
any feature of Qt which as been marked as deprecated (the exact warnings
depend on your compiler). Please consult the documentation of the
deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
You can also make your code fail to compile if you use deprecated APIs.
In order to do so, uncomment the following line.
You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cpp
mywidget.cppHEADERS +=
mywidget.hFORMS +=
mywidget.uiwin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/release/ -llibmupdf
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/debug/ -llibmupdfINCLUDEPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include
DEPENDPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/includewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/release/ -llibresources
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/debug/ -llibresourcesINCLUDEPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include
DEPENDPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/includewin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/release/ -llibthirdparty
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../mupdf/mupdf-1.12.0-source/platform/win32/debug/ -llibthirdpartyINCLUDEPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include
DEPENDPATH += $$PWD/../../../mupdf/mupdf-1.12.0-source/include -
@Aditya1309
You should remove the lib prefix:-lmupdf -lresources
-
Its complaining that -lmupdf is not found.