Skip to content

Include C++ program (makefile) #4226

Closed
Closed

Description

@ChristianMichelsen
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Issue

I am developing a small piece of Python software that loads the results of a C++ program (a csv-file) and makes some subsequent calculations on it and visualizes it. The C++ software does not need Python-bindings, since it right now works fine by calling it just with subprocess. The C++ software itself is compiled using a makefile which works fine on both my mac and the linux server we have available.

To make it super easy for the end users of my software, I want to include the C++ software in my package, such that they do not have to worry about this. Now comes the question:

Should I just:
1: include the compiled binary of the C++ software and distribute individual wheels for mac and linux or
2: include the source for the C++ software (from Github), including the makefile, and let people compile it themselves?

The problem is that the end users should have as easy an entry to this software as possible (they are used to Excel right now) and compiling anything themselves would be way out of the scope (which makes solution 2 a bit difficult).

I have tried searching for previous similar topics, but most results I find seems to be more related to Cython and what seems to me to be Python-bindings of C++ software.

I have included the makefile below, in case that changes anything:

#modied from htslib makefile
FLAGS=-O3 -std=c++11

CFLAGS += $(FLAGS)
CXXFLAGS += $(FLAGS)

CSRC = $(wildcard *.c) 
CXXSRC = $(wildcard *.cpp)
OBJ = $(CSRC:.c=.o) $(CXXSRC:.cpp=.o)

all: softwarename

PACKAGE_VERSION  = 0.1

ifneq "$(wildcard .git)" ""
PACKAGE_VERSION := $(shell git describe --always --dirty)
version.h: $(if $(wildcard version.h),$(if $(findstring "$(PACKAGE_VERSION)",$(shell cat version.h)),,force))
endif

version.h:
	echo '#define SOFTWARENAME_VERSION "$(PACKAGE_VERSION)"' > $@


# Adjust $(HTSSRC) to point to your top-level htslib directory
ifdef HTSSRC
$(info HTSSRC defined)
HTS_INCDIR=$(realpath $(HTSSRC))
HTS_LIBDIR=$(realpath $(HTSSRC))/libhts.a
else
$(info HTSSRC not defined, assuming systemwide installation -lhts)
endif


-include $(OBJ:.o=.d)

ifdef HTSSRC
%.o: %.c
	$(CC) -c  $(CFLAGS) -I$(HTS_INCDIR) $*.c
	$(CC) -MM $(CFLAGS)  -I$(HTS_INCDIR) $*.c >$*.d

%.o: %.cpp
	$(CXX) -c  $(CXXFLAGS)  -I$(HTS_INCDIR) $*.cpp
	$(CXX) -MM $(CXXFLAGS)  -I$(HTS_INCDIR) $*.cpp >$*.d

softwarename: version.h $(OBJ)
	$(CXX) $(FLAGS)  -o softwarename *.o $(HTS_LIBDIR) -lz -llzma -lbz2 -lpthread -lcurl 
else
%.o: %.c
	$(CC) -c  $(CFLAGS)  $*.c
	$(CC) -MM $(CFLAGS)  $*.c >$*.d

%.o: %.cpp
	$(CXX) -c  $(CXXFLAGS)  $*.cpp
	$(CXX) -MM $(CXXFLAGS)  $*.cpp >$*.d

softwarename: version.h $(OBJ)
	$(CXX) $(FLAGS)  -o softwarename *.o -lz -llzma -lbz2 -lpthread -lcurl -lhts
endif

clean:	
	rm  -f softwarename *.o *.d version.h

force:

Activity

  1. finswimmer commented on Jul 23, 2021

    @finswimmer
    Member

    Hello @ChristianMichelsen,

    I move this issue to a discussion because it is not a poetry issue. But maybe others are interested in this topic as well.

    fin swimmer

  2. locked and limited conversation to collaborators on Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions