Wireshark-dev: Re: [Wireshark-dev] Mac Build Error
From: David Morsberger <dave@xxxxxxxxxxxxxx>
Date: Thu, 21 Jan 2016 15:10:30 -0500


On Thu, Jan 21, 2016 at 2:29 PM, Guy Harris <guy@xxxxxxxxxxxx> wrote:
On Jan 21, 2016, at 6:08 AM, David Morsberger <dave@xxxxxxxxxxxxxx> wrote:

> It appears the linker isn’t called when the -c and the -o options are present.

Correct.  It's not *supposed* to be called.  In UNIX C compilers, the "-c" flag means "compile to an object file, but don't link the resulting object file into an executable file"; it's the standard option used if you have a program that's built from more than one object file.

> The cmake logic in CMakeLists.txt is basically:
>
>    SET(CMAKE_REQUIRED_FLAGS "${_FLAG}")
>    CHECK_C_SOURCE_RUNS(“int main() { return 0;}" ${_RESULT})

The documentation for the CHECK_C_SOURCE_RUNS() macro is

        * CheckCSourceRuns: Check if the given C source code compiles and runs.



I think this is a bug in cmake because:
 
1. the 'and run' in "CheckCSourceRuns: Check if the given C source code compiles and runs" should imply linking and executing the software.

2. The CHECK_C_SOURCE_COMPILES should only try and compile source

There is no other way to test that a program links since the '-c <file.c> and -o <file.o>' options result in only compiling.


I guess, with Makefiles, the linking is done with a compiler command (another UNIX tradition) and the -Wl,--as-needed flag is passed on the link command line, but, with Xcode, it's not done with a compiler command, and the C flags aren't passed to the link phase at all.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe