Thread: Unable to debug pcre program

  1. #1
    Registered User
    Join Date
    Jun 2018
    Posts
    10

    Unable to debug pcre program

    Greeting to all.

    In a previous post, I was struggling to generate a Cmake that could actually compile a source code example using pcre. Regardless of the success I've had accomplishing this, the -g flag does not add apparently debug symbols. Here's is an example of my Cmake

    Code:
    cmake_minimum_required(VERSION 2.8.9)
    project(directory_test)
    
    #Include directories.h
    #include_directories(include)
    
    # Add sources
    file(GLOB SOURCES "src/*.c")
    
    # Creates an executable
    add_executable(main ${SOURCES})
    
    # Add external library
    target_link_libraries(main -lpcre)
    
    # Add compilation flags
    target_compile_options(main PUBLIC -Wall -g -o pcredemo.c)
    Any hint or help would be very appreciated.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I don't use CMake but I am extremely skeptical about that last line, unless you are deliberately trying to make your executable file called "pcredemo.c" which seems ... odd. Does your pcredemo.c file still look like source code? What's the actual makefile that was generated?

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    To the extent there is a common theme in your posts, though, it seems to be that you are missing the point of this line:
    Code:
    file(GLOB SOURCES "src/*.c")
    which is designed to add all your *.c files into your project. Consequently, any time a .c file appears in your CMake file, it is an error (because all your .c files should be accounted for here). It feels like you're adding the .c file you want to be compiled at the end of some random lines where they don't really belong, instead of putting your .c files in the src/ directory ("src" stands for "source", so all your code should be there).

  4. #4
    Registered User
    Join Date
    Jun 2018
    Posts
    10
    You were right, I was making an amateur mistake, thanks for the help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cannot generate cmake for pcre in c
    By diego31416 in forum C Programming
    Replies: 1
    Last Post: 10-28-2018, 11:56 PM
  2. unable to run program
    By Arunjib Roy in forum C Programming
    Replies: 15
    Last Post: 12-20-2013, 11:25 PM
  3. PCRE string issue
    By aboosoyeed in forum C Programming
    Replies: 6
    Last Post: 03-23-2012, 06:59 PM
  4. Replies: 8
    Last Post: 05-01-2011, 07:05 AM
  5. Program unable to print anything
    By SasDutta in forum C Programming
    Replies: 7
    Last Post: 07-23-2010, 10:04 AM

Tags for this Thread