diff --git a/ex4.md b/ex4.md new file mode 100644 index 0000000..a471ae1 --- /dev/null +++ b/ex4.md @@ -0,0 +1,5 @@ +1. Use ex4 folder to find out how to create shared libary (eclipse IDE in this case) + +2. Create a shared library of your code, which solved one of the Rosaild's problem + +3. Use any of the shared libraries of your chosen friend \ No newline at end of file diff --git a/ex4/lib/.cproject b/ex4/lib/.cproject new file mode 100644 index 0000000..0b03f10 --- /dev/null +++ b/ex4/lib/.cproject @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ex4/lib/.project b/ex4/lib/.project new file mode 100644 index 0000000..c36bbb8 --- /dev/null +++ b/ex4/lib/.project @@ -0,0 +1,27 @@ + + + lib-cpp-shared + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/ex4/lib/.settings/language.settings.xml b/ex4/lib/.settings/language.settings.xml new file mode 100644 index 0000000..17f664e --- /dev/null +++ b/ex4/lib/.settings/language.settings.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ex4/lib/Debug/TestClass.d b/ex4/lib/Debug/TestClass.d new file mode 100644 index 0000000..f9d4887 --- /dev/null +++ b/ex4/lib/Debug/TestClass.d @@ -0,0 +1,2 @@ +TestClass.o: ../TestClass.cpp ../TestClass.h +../TestClass.h: diff --git a/ex4/lib/Debug/TestClass.o b/ex4/lib/Debug/TestClass.o new file mode 100644 index 0000000..88c0048 Binary files /dev/null and b/ex4/lib/Debug/TestClass.o differ diff --git a/ex4/lib/Debug/liblib-cpp-shared.so b/ex4/lib/Debug/liblib-cpp-shared.so new file mode 100755 index 0000000..89cc5c5 Binary files /dev/null and b/ex4/lib/Debug/liblib-cpp-shared.so differ diff --git a/ex4/lib/Debug/makefile b/ex4/lib/Debug/makefile new file mode 100644 index 0000000..73272e6 --- /dev/null +++ b/ex4/lib/Debug/makefile @@ -0,0 +1,69 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +-include ../makefile.init + +RM := rm -rf + +# All of the sources participating in the build are defined here +-include sources.mk +-include subdir.mk +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(C++_DEPS)),) +-include $(C++_DEPS) +endif +ifneq ($(strip $(CC_DEPS)),) +-include $(CC_DEPS) +endif +ifneq ($(strip $(CPP_DEPS)),) +-include $(CPP_DEPS) +endif +ifneq ($(strip $(CXX_DEPS)),) +-include $(CXX_DEPS) +endif +ifneq ($(strip $(C_DEPS)),) +-include $(C_DEPS) +endif +ifneq ($(strip $(C_UPPER_DEPS)),) +-include $(C_UPPER_DEPS) +endif +endif + +-include ../makefile.defs + +OPTIONAL_TOOL_DEPS := \ +$(wildcard ../makefile.defs) \ +$(wildcard ../makefile.init) \ +$(wildcard ../makefile.targets) \ + + +BUILD_ARTIFACT_NAME := lib-cpp-shared +BUILD_ARTIFACT_EXTENSION := so +BUILD_ARTIFACT_PREFIX := lib +BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),) + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: main-build + +# Main-build Target +main-build: liblib-cpp-shared.so + +# Tool invocations +liblib-cpp-shared.so: $(OBJS) $(USER_OBJS) makefile $(OPTIONAL_TOOL_DEPS) + @echo 'Building target: $@' + @echo 'Invoking: GCC C++ Linker' + g++ -shared -o "liblib-cpp-shared.so" $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Finished building target: $@' + @echo ' ' + +# Other Targets +clean: + -$(RM) liblib-cpp-shared.so + -@echo ' ' + +.PHONY: all clean dependents main-build + +-include ../makefile.targets diff --git a/ex4/lib/Debug/sources.mk b/ex4/lib/Debug/sources.mk new file mode 100644 index 0000000..ee24565 --- /dev/null +++ b/ex4/lib/Debug/sources.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +ASM_SRCS := +C++_SRCS := +CC_SRCS := +CPP_SRCS := +CXX_SRCS := +C_SRCS := +C_UPPER_SRCS := +OBJ_SRCS := +O_SRCS := +S_UPPER_SRCS := +C++_DEPS := +CC_DEPS := +CPP_DEPS := +CXX_DEPS := +C_DEPS := +C_UPPER_DEPS := +LIBRARIES := +OBJS := + +# Every subdirectory with source files must be described here +SUBDIRS := \ +. \ + diff --git a/ex4/lib/Debug/subdir.mk b/ex4/lib/Debug/subdir.mk new file mode 100644 index 0000000..d2d57d0 --- /dev/null +++ b/ex4/lib/Debug/subdir.mk @@ -0,0 +1,31 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../TestClass.cpp + +CPP_DEPS += \ +./TestClass.d + +OBJS += \ +./TestClass.o + + +# Each subdirectory must supply rules for building sources it contributes +%.o: ../%.cpp subdir.mk + @echo 'Building file: $<' + @echo 'Invoking: GCC C++ Compiler' + g++ -O0 -g3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -o "$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + +clean: clean--2e- + +clean--2e-: + -$(RM) ./TestClass.d ./TestClass.o + +.PHONY: clean--2e- + diff --git a/ex4/lib/TestClass.cpp b/ex4/lib/TestClass.cpp new file mode 100644 index 0000000..e94e0a1 --- /dev/null +++ b/ex4/lib/TestClass.cpp @@ -0,0 +1,26 @@ +/* + * TestClass.cpp + * + * Created on: Oct 25, 2024 + * Author: ahypki + */ + +#include "TestClass.h" + +TestClass::TestClass() { + // TODO Auto-generated constructor stub + +} + +TestClass::~TestClass() { + // TODO Auto-generated destructor stub +} + + +int TestClass::getTestValue() { + return testValue; +} + +void TestClass::setTestValue(int testValue = 0) { + this->testValue = testValue; +} diff --git a/ex4/lib/TestClass.h b/ex4/lib/TestClass.h new file mode 100644 index 0000000..29f015c --- /dev/null +++ b/ex4/lib/TestClass.h @@ -0,0 +1,23 @@ +/* + * TestClass.h + * + * Created on: Oct 25, 2024 + * Author: ahypki + */ + +#ifndef TESTCLASS_H_ +#define TESTCLASS_H_ + +class TestClass { +private: + int testValue = 0; + +public: + TestClass(); + virtual ~TestClass(); + int getTestValue(); + + void setTestValue(int testValue); +}; + +#endif /* TESTCLASS_H_ */ diff --git a/ex4/main/.cproject b/ex4/main/.cproject new file mode 100644 index 0000000..13ab706 --- /dev/null +++ b/ex4/main/.cproject @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ex4/main/.project b/ex4/main/.project new file mode 100644 index 0000000..4366bad --- /dev/null +++ b/ex4/main/.project @@ -0,0 +1,27 @@ + + + main-using-lib-cpp-shared + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/ex4/main/.settings/language.settings.xml b/ex4/main/.settings/language.settings.xml new file mode 100644 index 0000000..d7db426 --- /dev/null +++ b/ex4/main/.settings/language.settings.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ex4/main/.settings/org.eclipse.cdt.core.prefs b/ex4/main/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 0000000..d426419 --- /dev/null +++ b/ex4/main/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +environment/project/cdt.managedbuild.config.gnu.exe.debug.1968834354/LD_LIBRARY_PATH/delimiter=\: +environment/project/cdt.managedbuild.config.gnu.exe.debug.1968834354/LD_LIBRARY_PATH/operation=append +environment/project/cdt.managedbuild.config.gnu.exe.debug.1968834354/LD_LIBRARY_PATH/value=$LD_LIBRARY_PATH\:/home/ahypki/projekty/wmii-2023-bio-prog-obiektowe/ex4/lib/Debug/ +environment/project/cdt.managedbuild.config.gnu.exe.debug.1968834354/append=true +environment/project/cdt.managedbuild.config.gnu.exe.debug.1968834354/appendContributed=true +environment/project/cdt.managedbuild.config.gnu.exe.release.1370620746/LD_LIBRARY_PATH/delimiter=\: +environment/project/cdt.managedbuild.config.gnu.exe.release.1370620746/LD_LIBRARY_PATH/operation=append +environment/project/cdt.managedbuild.config.gnu.exe.release.1370620746/LD_LIBRARY_PATH/value=$LD_LIBRARY_PATH\:/home/ahypki/projekty/wmii-2023-bio-prog-obiektowe/ex4/lib/Debug/ +environment/project/cdt.managedbuild.config.gnu.exe.release.1370620746/append=true +environment/project/cdt.managedbuild.config.gnu.exe.release.1370620746/appendContributed=true diff --git a/ex4/main/src/main-using-lib-cpp-shared.cpp b/ex4/main/src/main-using-lib-cpp-shared.cpp new file mode 100644 index 0000000..a76a6a7 --- /dev/null +++ b/ex4/main/src/main-using-lib-cpp-shared.cpp @@ -0,0 +1,24 @@ +//============================================================================ +// Name : main-using-lib-cpp-shared.cpp +// Author : +// Version : +// Copyright : Your copyright notice +// Description : Hello World in C++, Ansi-style +//============================================================================ + +#include +#include "../../lib/TestClass.h" + +using namespace std; + +int main() { + cout << "!!!Hello World from a project which will use my shared library!!!" << endl; // prints !!!Hello World!!! + + TestClass tc = TestClass(); + tc.setTestValue(13); + + cout << "A value from TestClass: " << tc.getTestValue() << endl; + + cout << "Finished" << endl; + return 0; +}