Results 1 to 2 of 2

Thread: qmake+flex dependency problem

  1. #1
    Join Date
    Sep 2007
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default qmake+flex dependency problem

    Hi,

    I'm trying to use flex with qmake but I can't get the dependencies right. I want to keep the generated code in separate files. Here's a simple test to illustrate the problem:

    main.cpp:
    Qt Code:
    1. #include "parser.h"
    2.  
    3. int main(int argc, char ** argv)
    4. {
    5. argv++; argc--;
    6.  
    7. if(--argc > 0)
    8. parserin = fopen(++argv[0], "r");
    9. else parserin = stdin;
    10.  
    11. parserlex();
    12.  
    13. return 0;
    14. }
    To copy to clipboard, switch view to plain text mode 

    parser.l:
    Qt Code:
    1. %option noyywrap
    2.  
    3. %%
    4.  
    5. %%
    To copy to clipboard, switch view to plain text mode 

    And finally the makefile:
    Qt Code:
    1. TEMPLATE = app
    2.  
    3. SOURCES += main.cpp
    4.  
    5. LEXSOURCES += parser.l
    6.  
    7. QMAKE_LEX = flex
    8. QMAKE_LEXFLAGS = --header-file=parser.h
    9.  
    10. TARGET = ParserTest
    11.  
    12. LIBS += -lfl
    13.  
    14. CONFIG -= qt
    To copy to clipboard, switch view to plain text mode 

    The problem is that qmake tries to compile main.cpp first that depends on the generated parser.h (which doesn't exist). How can I tell qmake about this dependency? I tried defining custom compilers for flex, but the dependency problem is still there.

  2. #2
    Join Date
    Sep 2007
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: qmake+flex dependency problem

    A simple solution seems to be building the flex stuff into a library and then linking that against a separate application so the order of compilation doesn't matter.

    Though I'm still curious how to define the dependencies so that the application in the first post is built correctly.

Similar Threads

  1. Flex, Bison and qmake
    By Hydragyrum in forum Qt Programming
    Replies: 5
    Last Post: 2nd May 2011, 15:52
  2. Qt 4.3.1 & MinGW 5.1.3 & MSYS 1.0 qmake problem
    By mdecandia in forum Installation and Deployment
    Replies: 2
    Last Post: 2nd October 2008, 16:52
  3. I have a problem about qmake
    By wsinw in forum Installation and Deployment
    Replies: 3
    Last Post: 29th May 2007, 12:04
  4. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  5. Problem when using qmake for .vcproj file generation
    By Conel in forum Qt Programming
    Replies: 3
    Last Post: 4th December 2006, 14:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.